(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestGetModFile(t *testing.T) { |
| 11 | dir := t.TempDir() |
| 12 | err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte(` |
| 13 | module example.com/foo |
| 14 | |
| 15 | require example.com/whatever v1.2.3 |
| 16 | |
| 17 | tool example.com/whatever/cmd/thing |
| 18 | |
| 19 | go 1.23.4 |
| 20 | `), 0o644) |
| 21 | if err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | |
| 25 | mod, err := GetModFile(dir) |
| 26 | if err != nil { |
| 27 | t.Fatal(err) |
| 28 | } |
| 29 | |
| 30 | if mod.Module.Mod.Path != "example.com/foo" { |
| 31 | t.Fatalf("unexpected module path: %v", mod.Module.Mod.Path) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | func TestGetModFileErrors(t *testing.T) { |
| 36 | t.Run("DoesNotExist", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…