feat: SEO backend output (2/4)
This commit is contained in:
1 parent
0eb46b0d74
commit
eb9876fde3
32 files changed
+3859
-65
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSeoOutputLayering(t *testing.T) {
|
||||
forbidden := []string{"gorm", "net/http", "go-chi", "persistence", "mailer", "api/"}
|
||||
files := []string{
|
||||
"seoBody.go", "seoRules.go", "ResolveArticleSEO.go", "CheckArticleSEO.go", "ListSitemap.go", "ListArticles.go",
|
||||
}
|
||||
for _, name := range files {
|
||||
parsed, err := parser.ParseFile(token.NewFileSet(), filepath.Join("..", "internal", "infrastructure", "useCases", name), nil, parser.ImportsOnly)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, spec := range parsed.Imports {
|
||||
for _, word := range forbidden {
|
||||
if strings.Contains(spec.Path.Value, word) {
|
||||
t.Errorf("%s imports %s", name, spec.Path.Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, name := range []string{"seoStatus.go", "seoResolved.go"} {
|
||||
parsed, err := parser.ParseFile(token.NewFileSet(), filepath.Join("..", "internal", "domain", "article", name), nil, parser.ImportsOnly)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, spec := range parsed.Imports {
|
||||
if strings.Contains(spec.Path.Value, ".") {
|
||||
t.Errorf("%s imports %s", name, spec.Path.Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user