internal/shape/golist_test.go
Ref: Size: 872 B History
package shape
import "testing"
// Shells out to the real `go list`; asserts the live module classifies cleanly.
// If a new top-level package appears that matches no rule in classify(), it
// lands in Unclassified and this fails — forcing a deliberate classification.
func TestNoUnclassifiedPackagesInModule(t *testing.T) {
raw, err := goList()
if err != nil {
t.Fatalf("go list: %v", err)
}
m := Build(raw)
if len(m.Packages) == 0 {
t.Fatal("go list returned no packages")
}
for _, p := range m.Packages {
if p.Plane == PlaneUnclassified {
t.Errorf("package %q is unclassified — add a rule to classify()", p.ImportPath)
}
}
}
func TestGenerateProducesStableJSON(t *testing.T) {
a, err := Generate()
if err != nil {
t.Fatal(err)
}
b, _ := Generate()
if string(a) != string(b) {
t.Error("Generate output is not stable across calls")
}
}