MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestCheckFileImportersOutput

Function TestCheckFileImportersOutput

cmd/hooks_test.go:362–453  ·  view source on GitHub ↗

TestCheckFileImportersOutput tests the output format for different scenarios

(t *testing.T)

Source from the content-addressed store, hash-verified

360
361// TestCheckFileImportersOutput tests the output format for different scenarios
362func TestCheckFileImportersOutput(t *testing.T) {
363 tests := []struct {
364 name string
365 info *hubInfo
366 filePath string
367 wantContains []string
368 wantNotContain []string
369 }{
370 {
371 name: "hub file with many importers",
372 info: &hubInfo{
373 Importers: map[string][]string{
374 "types.go": {"a.go", "b.go", "c.go", "d.go", "e.go", "f.go"},
375 },
376 Imports: map[string][]string{},
377 },
378 filePath: "types.go",
379 wantContains: []string{
380 "HUB FILE",
381 "types.go",
382 "Imported by 6 files",
383 "wide impact",
384 "Dependents:",
385 },
386 },
387 {
388 name: "non-hub file with some importers",
389 info: &hubInfo{
390 Importers: map[string][]string{
391 "utils.go": {"main.go", "cmd.go"},
392 },
393 Imports: map[string][]string{},
394 },
395 filePath: "utils.go",
396 wantContains: []string{
397 "File:",
398 "utils.go",
399 "Imported by 2 file(s)",
400 },
401 wantNotContain: []string{
402 "HUB FILE",
403 "wide impact",
404 },
405 },
406 {
407 name: "file with no importers",
408 info: &hubInfo{
409 Importers: map[string][]string{},
410 Imports: map[string][]string{},
411 },
412 filePath: "lonely.go",
413 wantContains: []string{}, // should produce no output
414 wantNotContain: []string{"HUB FILE", "File:", "Imported by"},
415 },
416 {
417 name: "file that imports hubs",
418 info: &hubInfo{
419 Importers: map[string][]string{

Callers

nothing calls this directly

Calls 2

captureOutputFunction · 0.85

Tested by

no test coverage detected