(t *testing.T)
| 33 | } |
| 34 | |
| 35 | func TestGetModFileErrors(t *testing.T) { |
| 36 | t.Run("DoesNotExist", func(t *testing.T) { |
| 37 | _, err := GetModFile(t.TempDir()) |
| 38 | if err == nil { |
| 39 | t.Fatal("expected error") |
| 40 | } |
| 41 | if !errors.Is(err, os.ErrNotExist) { |
| 42 | t.Fatalf("unexpected error: %v", err) |
| 43 | } |
| 44 | }) |
| 45 | |
| 46 | t.Run("SyntaxError", func(t *testing.T) { |
| 47 | dir := t.TempDir() |
| 48 | err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte("syntax error"), 0o644) |
| 49 | if err != nil { |
| 50 | t.Fatal(err) |
| 51 | } |
| 52 | |
| 53 | if _, err := GetModFile(dir); err == nil { |
| 54 | t.Fatal("expected error") |
| 55 | } |
| 56 | }) |
| 57 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…