(t *testing.T)
| 241 | } |
| 242 | |
| 243 | func TestIndexOpen(t *testing.T) { |
| 244 | t.Parallel() |
| 245 | repo := createTestRepo(t) |
| 246 | defer cleanupTestRepo(t, repo) |
| 247 | |
| 248 | path := repo.Workdir() + "/heyindex" |
| 249 | |
| 250 | _, err := os.Stat(path) |
| 251 | if !os.IsNotExist(err) { |
| 252 | t.Fatal("new index file already exists") |
| 253 | } |
| 254 | |
| 255 | idx, err := OpenIndex(path) |
| 256 | checkFatal(t, err) |
| 257 | |
| 258 | if path != idx.Path() { |
| 259 | t.Fatalf("mismatched index paths, expected %v, got %v", path, idx.Path()) |
| 260 | } |
| 261 | |
| 262 | err = idx.Write() |
| 263 | checkFatal(t, err) |
| 264 | |
| 265 | _, err = os.Stat(path) |
| 266 | if os.IsNotExist(err) { |
| 267 | t.Fatal("new index file did not get written") |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func checkFatal(t *testing.T, err error) { |
| 272 | if err == nil { |
nothing calls this directly
no test coverage detected
searching dependent graphs…