(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func TestBranchIteratorEach(t *testing.T) { |
| 31 | t.Parallel() |
| 32 | repo := createTestRepo(t) |
| 33 | defer cleanupTestRepo(t, repo) |
| 34 | |
| 35 | seedTestRepo(t, repo) |
| 36 | |
| 37 | i, err := repo.NewBranchIterator(BranchLocal) |
| 38 | checkFatal(t, err) |
| 39 | |
| 40 | var names []string |
| 41 | f := func(b *Branch, t BranchType) error { |
| 42 | name, err := b.Name() |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | |
| 47 | names = append(names, name) |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | err = i.ForEach(f) |
| 52 | if err != nil && !IsErrorCode(err, ErrorCodeIterOver) { |
| 53 | t.Fatal(err) |
| 54 | } |
| 55 | |
| 56 | if len(names) != 1 { |
| 57 | t.Fatalf("expect 1 branch, but it was %d\n", len(names)) |
| 58 | } |
| 59 | |
| 60 | if names[0] != "master" { |
| 61 | t.Fatalf("expect branch master, but it was %s\n", names[0]) |
| 62 | } |
| 63 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…