|
1 | 1 | package fixtures_test
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "strconv" |
4 | 5 | "testing"
|
5 | 6 |
|
6 | 7 | fixtures "github.com/go-git/go-git-fixtures/v5"
|
@@ -67,3 +68,94 @@ func TestRevFiles(t *testing.T) {
|
67 | 68 | assert.NotNil(t, f)
|
68 | 69 | assert.NotNil(t, f.Rev(), "failed to get rev file")
|
69 | 70 | }
|
| 71 | + |
| 72 | +func TestAll(t *testing.T) { |
| 73 | + fs := fixtures.All() |
| 74 | + |
| 75 | + assert.Len(t, fs, 38) |
| 76 | +} |
| 77 | + |
| 78 | +func TestByTag(t *testing.T) { |
| 79 | + t.Parallel() |
| 80 | + tests := []struct { |
| 81 | + tag string |
| 82 | + len int |
| 83 | + }{ |
| 84 | + {tag: "packfile", len: 20}, |
| 85 | + {tag: "ofs-delta", len: 3}, |
| 86 | + {tag: ".git", len: 12}, |
| 87 | + {tag: "merge-conflict", len: 1}, |
| 88 | + {tag: "worktree", len: 6}, |
| 89 | + {tag: "submodule", len: 1}, |
| 90 | + {tag: "tags", len: 1}, |
| 91 | + {tag: "notes", len: 1}, |
| 92 | + {tag: "multi-packfile", len: 1}, |
| 93 | + {tag: "diff-tree", len: 7}, |
| 94 | + {tag: "packfile-sha256", len: 1}, |
| 95 | + } |
| 96 | + |
| 97 | + for _, tc := range tests { |
| 98 | + tc := tc |
| 99 | + |
| 100 | + t.Run(tc.tag, func(t *testing.T) { |
| 101 | + t.Parallel() |
| 102 | + |
| 103 | + f := fixtures.ByTag(tc.tag) |
| 104 | + assert.Len(t, f, tc.len) |
| 105 | + }) |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +func TestByURL(t *testing.T) { |
| 110 | + t.Parallel() |
| 111 | + |
| 112 | + tests := []struct { |
| 113 | + URL string |
| 114 | + len int |
| 115 | + }{ |
| 116 | + {URL: "https://github.com/git-fixtures/root-references.git", len: 1}, |
| 117 | + {URL: "https://github.com/git-fixtures/basic.git", len: 9}, |
| 118 | + {URL: "https://github.com/git-fixtures/submodule.git", len: 1}, |
| 119 | + {URL: "https://github.com/src-d/go-git.git", len: 1}, |
| 120 | + {URL: "https://github.com/git-fixtures/tags.git", len: 1}, |
| 121 | + {URL: "https://github.com/spinnaker/spinnaker.git", len: 1}, |
| 122 | + {URL: "https://github.com/jamesob/desk.git", len: 1}, |
| 123 | + {URL: "https://github.com/cpcs499/Final_Pres_P.git", len: 1}, |
| 124 | + {URL: "https://github.com/github/gem-builder.git", len: 1}, |
| 125 | + {URL: "https://github.com/githubtraining/example-branches.git", len: 1}, |
| 126 | + {URL: "https://github.com/rumpkernel/rumprun-xen.git", len: 1}, |
| 127 | + {URL: "https://github.com/mcuadros/skeetr.git", len: 1}, |
| 128 | + {URL: "https://github.com/dezfowler/LiteMock.git", len: 1}, |
| 129 | + {URL: "https://github.com/tyba/storable.git", len: 1}, |
| 130 | + {URL: "https://github.com/toqueteos/ts3.git", len: 1}, |
| 131 | + {URL: "https://github.com/git-fixtures/empty.git", len: 1}, |
| 132 | + } |
| 133 | + |
| 134 | + for _, tc := range tests { |
| 135 | + tc := tc |
| 136 | + |
| 137 | + t.Run(tc.URL, func(t *testing.T) { |
| 138 | + t.Parallel() |
| 139 | + |
| 140 | + f := fixtures.ByURL(tc.URL) |
| 141 | + assert.Len(t, f, tc.len) |
| 142 | + }) |
| 143 | + } |
| 144 | +} |
| 145 | + |
| 146 | +func TestIdx(t *testing.T) { |
| 147 | + t.Parallel() |
| 148 | + |
| 149 | + for i, f := range fixtures.ByTag("packfile") { |
| 150 | + f := f |
| 151 | + t.Run("#"+strconv.Itoa(i), func(t *testing.T) { |
| 152 | + t.Parallel() |
| 153 | + |
| 154 | + index := f.Idx() |
| 155 | + assert.NotNil(t, index) |
| 156 | + |
| 157 | + err := index.Close() |
| 158 | + assert.NoError(t, err) |
| 159 | + }) |
| 160 | + } |
| 161 | +} |
0 commit comments