26 lines
686 B
Go
26 lines
686 B
Go
package test
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRoleDomainImportsOnlyTheStandardLibrary(t *testing.T) {
|
|
t.Run("The role domain imports only the standard library", func(t *testing.T) {
|
|
files, err := filepath.Glob("../internal/domain/role/*.go")
|
|
if err != nil || len(files) == 0 {
|
|
t.Fatalf("no role domain files: %v", err)
|
|
}
|
|
for _, file := range files {
|
|
relative := strings.TrimPrefix(filepath.ToSlash(file), "../")
|
|
for _, imported := range importsOf(t, relative) {
|
|
first := strings.Split(imported, "/")[0]
|
|
if strings.Contains(first, ".") || first == "RenewCMS" {
|
|
t.Errorf("%s imports %s", relative, imported)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|