(t *testing.T)
| 263 | } |
| 264 | |
| 265 | func TestDetectModule(t *testing.T) { |
| 266 | tests := []struct { |
| 267 | name string |
| 268 | content string |
| 269 | expected string |
| 270 | }{ |
| 271 | {name: "module exists", content: "module github.com/example/project\n\ngo 1.22\n", expected: "github.com/example/project"}, |
| 272 | {name: "module missing", content: "go 1.22\n", expected: ""}, |
| 273 | } |
| 274 | |
| 275 | for _, tt := range tests { |
| 276 | t.Run(tt.name, func(t *testing.T) { |
| 277 | root := t.TempDir() |
| 278 | if tt.content != "" { |
| 279 | if err := os.WriteFile(filepath.Join(root, "go.mod"), []byte(tt.content), 0o644); err != nil { |
| 280 | t.Fatal(err) |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | got := detectModule(root) |
| 285 | if got != tt.expected { |
| 286 | t.Errorf("detectModule() = %q, want %q", got, tt.expected) |
| 287 | } |
| 288 | }) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | func TestFileGraphHubAndConnectedFiles(t *testing.T) { |
| 293 | fg := &FileGraph{ |
nothing calls this directly
no test coverage detected