MCPcopy
hub / github.com/git-lfs/git-lfs / TestLocalRefs

Function TestLocalRefs

git/git_test.go:620–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

618}
619
620func TestLocalRefs(t *testing.T) {
621 repo := test.NewRepo(t)
622 repo.Pushd()
623 defer func() {
624 repo.Popd()
625 repo.Cleanup()
626 }()
627
628 repo.AddCommits([]*test.CommitInput{
629 {
630 Files: []*test.FileInput{
631 {Filename: "file1.txt", Size: 20},
632 },
633 },
634 {
635 NewBranch: "branch",
636 ParentBranches: []string{"master"},
637 Files: []*test.FileInput{
638 {Filename: "file1.txt", Size: 20},
639 },
640 },
641 })
642
643 test.RunGitCommand(t, true, "tag", "v1")
644
645 refs, err := LocalRefs()
646 if err != nil {
647 t.Fatal(err)
648 }
649
650 actual := make(map[string]bool)
651 for _, r := range refs {
652 t.Logf("REF: %s", r.Name)
653 switch r.Type {
654 case RefTypeHEAD:
655 t.Errorf("Local HEAD ref: %v", r)
656 case RefTypeOther:
657 t.Errorf("Stash or unknown ref: %v", r)
658 default:
659 actual[r.Name] = true
660 }
661 }
662
663 expected := []string{"master", "branch", "v1"}
664 found := 0
665 for _, refname := range expected {
666 if actual[refname] {
667 found += 1
668 } else {
669 t.Errorf("could not find ref %q", refname)
670 }
671 }
672
673 if found != len(expected) {
674 t.Errorf("Unexpected local refs: %v", actual)
675 }
676}
677

Callers

nothing calls this directly

Calls 8

PushdMethod · 0.95
PopdMethod · 0.95
CleanupMethod · 0.95
AddCommitsMethod · 0.95
LocalRefsFunction · 0.85
FatalMethod · 0.80
LogfMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected