package guards import ( "strings" "testing" ) // sealtestImport is the plaintext-gate test helper package. Its own doc // comment already says this — "this package must never be imported from // non-test code: doing so would drag the testing package into the // production binary" — but until now that rested on the comment alone. const sealtestImport = "amadan.net/oficina/sheets/internal/sheets/sealtest" // TestSealtestOnlyImportedByTests fails on any non-_test.go file that // imports sealtest. func TestSealtestOnlyImportedByTests(t *testing.T) { root := repoRoot(t) for _, path := range goFiles(t, root) { if strings.HasSuffix(path, "_test.go") { continue } rel := relPath(t, root, path) for _, imp := range fileImports(t, path) { if imp == sealtestImport { t.Errorf("%s: imports %q from non-test code (sealtest containment: sealtest imports testing, so it must stay test-only)", rel, sealtestImport) } } } }