package schutzaria import ( "go/parser" "go/token" "path/filepath" "strconv" "strings" "testing" ) func TestComponentBoundary(t *testing.T) { if Component != "schutzaria" { t.Fatal("component identity changed") } files, err := filepath.Glob("*.go") if err != nil { t.Fatal(err) } for _, file := range files { if strings.HasSuffix(file, "_test.go") { continue } ast, err := parser.ParseFile(token.NewFileSet(), file, nil, parser.ImportsOnly) if err != nil { t.Fatal(err) } for _, spec := range ast.Imports { path, err := strconv.Unquote(spec.Path.Value) if err != nil { t.Fatal(err) } for _, prefix := range []string{"pageswiki/internal", "database", "net", "os", "time"} { if path == prefix || strings.HasPrefix(path, prefix+"/") { t.Errorf("%s imports %s: evaluation must not acquire state, perform I/O or read time", file, path) } } } } }