MCPcopy Create free account
hub / github.com/marwan-at-work/mod / TestGetModFileErrors

Function TestGetModFileErrors

mod_test.go:35–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func 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}

Callers

nothing calls this directly

Calls 1

GetModFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…