package architecture import ( "go/parser" "go/token" "io/fs" "path/filepath" "strconv" "strings" "testing" ) // Provider access is HTTP only. Local Mongo repositories belong to SXCHNGE. func TestNoSendicoRuntimeOrPrivateTransportImports(t *testing.T) { err := filepath.WalkDir("../..", func(path string, d fs.DirEntry, err error) error { if err != nil { return err } if d.IsDir() || filepath.Ext(path) != ".go" { return nil } f, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.ImportsOnly) if err != nil { return err } for _, im := range f.Imports { name, err := strconv.Unquote(im.Path.Value) if err != nil { return err } for _, blocked := range []string{"github.com/tech/sendico/", "google.golang.org/grpc", "github.com/nats-io/", "/pkg/discovery", "/pkg/proto/"} { if strings.Contains(name, blocked) { t.Errorf("%s imports private provider transport or shared runtime: %s", path, name) } } } return nil }) if err != nil { t.Fatal(err) } }