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

Function TestGetModFile

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

Source from the content-addressed store, hash-verified

8)
9
10func TestGetModFile(t *testing.T) {
11 dir := t.TempDir()
12 err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte(`
13module example.com/foo
14
15require example.com/whatever v1.2.3
16
17tool example.com/whatever/cmd/thing
18
19go 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
35func TestGetModFileErrors(t *testing.T) {
36 t.Run("DoesNotExist", func(t *testing.T) {

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…