package scaffold import ( "os/exec" "strings" "testing" ) // This package is prose and a table of contents. It hands out embedded bytes and // says which of them carry a generated region; it renders nothing, resolves // nothing and reads no file off the disk. // // That matters because of what sits above it: internal/cmd imports this to write // a project's `.claude/` tree, and if this package imported the registry back the // two would be a cycle. The dependency walk, so a helper pulled in three packages // deep is caught as the same violation as one written at the top of a file. func TestScaffoldDependsOnNothing(t *testing.T) { out, err := exec.Command("go", "list", "-deps", ".").Output() if err != nil { t.Fatalf("go list: %v", err) } for _, dep := range strings.Fields(string(out)) { if dep == "git.noodles.cam/claude-skills/marketplace/cli/internal/scaffold" { continue } // A standard-library import path has no dot in its first element, // because it has no domain name in front of it. if first, _, _ := strings.Cut(dep, "/"); strings.Contains(first, ".") { t.Errorf("scaffold imports %s — these are embedded documents, and nothing else belongs here", dep) } } } // The other half: os and net/http are standard library, so "no third-party // imports" would not catch a read off the disk written by hand here. The whole // premise is that these documents travel INSIDE the binary — one os.ReadFile and // they are back to being files on a machine that may not have them. // // DIRECT imports, not the dependency walk — embed reaches io/fs on its own, and // the question this asks is what THIS package reaches for. func TestScaffoldReadsNothingOffTheDisk(t *testing.T) { forbidden := map[string]string{ "os": "these documents are embedded; a file read here is a file that can be missing", "os/exec": "nothing here shells out", "net/http": "nothing here is fetched", "net": "nothing here is fetched", "time": "a document has no clock in it", } out, err := exec.Command("go", "list", "-f", `{{join .Imports "\n"}}`, ".").Output() if err != nil { t.Fatalf("go list: %v", err) } for _, dep := range strings.Fields(string(out)) { if why, bad := forbidden[dep]; bad { t.Errorf("scaffold imports %s — %s", dep, why) } } }