Finish the domain pipeline cleanup
This commit is contained in:
@@ -189,6 +189,41 @@ func TestImportBoundaryRules(t *testing.T) {
|
||||
sourcePackage: "cli",
|
||||
importPath: moduleImportPrefix + "almanac/extract/events",
|
||||
},
|
||||
{
|
||||
name: "command production cannot import registrar",
|
||||
filename: "cmd/notarius/main.go",
|
||||
sourcePackage: "main",
|
||||
importPath: moduleImportPrefix + "almanac/register",
|
||||
wantError: true,
|
||||
},
|
||||
{
|
||||
name: "command production cannot import concrete leaf",
|
||||
filename: "cmd/notarius/main.go",
|
||||
sourcePackage: "main",
|
||||
importPath: moduleImportPrefix + "almanac/extract/events",
|
||||
wantError: true,
|
||||
},
|
||||
{
|
||||
name: "unknown production package cannot import concrete leaf",
|
||||
filename: "internal/application/bootstrap.go",
|
||||
sourcePackage: "application",
|
||||
importPath: moduleImportPrefix + "almanac/extract/events",
|
||||
wantError: true,
|
||||
},
|
||||
{
|
||||
name: "unknown production package cannot import registrar",
|
||||
filename: "internal/application/bootstrap.go",
|
||||
sourcePackage: "application",
|
||||
importPath: moduleImportPrefix + "almanac/register",
|
||||
wantError: true,
|
||||
},
|
||||
{
|
||||
name: "unknown test package is not a compatibility root",
|
||||
filename: "internal/application/bootstrap_test.go",
|
||||
sourcePackage: "application",
|
||||
importPath: moduleImportPrefix + "almanac/extract/events",
|
||||
wantError: true,
|
||||
},
|
||||
{
|
||||
name: "framework production cannot import concrete module",
|
||||
filename: "internal/framework/pipeline/runner.go",
|
||||
@@ -324,35 +359,41 @@ func validateImport(filename string, sourcePackage string, importPath string) er
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, "module integration composition is allowed only in black-box tests")
|
||||
}
|
||||
if !isTest && (strings.HasPrefix(filename, "internal/framework/") || strings.HasPrefix(filename, "internal/core/")) {
|
||||
sourceFamily, sourceRoot, sourceRegistrar := moduleFamilyForFile(filename)
|
||||
if sourceFamily != "" {
|
||||
if sourceRoot && sourceFamily == target.family && target.child {
|
||||
return importBoundaryViolation(filename, importPath, "family root must not import child packages")
|
||||
}
|
||||
if sourceFamily == target.family {
|
||||
return nil
|
||||
}
|
||||
if sourceFamily == "generic" {
|
||||
return importBoundaryViolation(filename, importPath, fmt.Sprintf("generic family must not import concrete family %q", target.family))
|
||||
}
|
||||
if target.family == "generic" {
|
||||
if sourceRegistrar {
|
||||
return nil
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, fmt.Sprintf("concrete family %q may import generic implementations only from its registrar", sourceFamily))
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, fmt.Sprintf("concrete family %q must not import concrete family %q", sourceFamily, target.family))
|
||||
}
|
||||
if isTest {
|
||||
if isCompatibilityTestFile(filename) {
|
||||
return nil
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, "direct module imports from non-module tests are allowed only in CLI, core, and framework compatibility-test roots")
|
||||
}
|
||||
if strings.HasPrefix(filename, "internal/framework/") || strings.HasPrefix(filename, "internal/core/") {
|
||||
return importBoundaryViolation(filename, importPath, "core and framework production code must not import module implementations")
|
||||
}
|
||||
if !isTest && strings.HasPrefix(filename, "internal/cli/") {
|
||||
if strings.HasPrefix(filename, "internal/cli/") {
|
||||
if target.registrar {
|
||||
return nil
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, "CLI production code may import only exact module family registrar packages")
|
||||
}
|
||||
sourceFamily, sourceRoot, sourceRegistrar := moduleFamilyForFile(filename)
|
||||
if sourceFamily == "" {
|
||||
return nil
|
||||
}
|
||||
if sourceRoot && sourceFamily == target.family && target.child {
|
||||
return importBoundaryViolation(filename, importPath, "family root must not import child packages")
|
||||
}
|
||||
if sourceFamily == target.family {
|
||||
return nil
|
||||
}
|
||||
if sourceFamily == "generic" {
|
||||
return importBoundaryViolation(filename, importPath, fmt.Sprintf("generic family must not import concrete family %q", target.family))
|
||||
}
|
||||
if target.family == "generic" {
|
||||
if sourceRegistrar {
|
||||
return nil
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, fmt.Sprintf("concrete family %q may import generic implementations only from its registrar", sourceFamily))
|
||||
}
|
||||
return importBoundaryViolation(filename, importPath, fmt.Sprintf("concrete family %q must not import concrete family %q", sourceFamily, target.family))
|
||||
return importBoundaryViolation(filename, importPath, "production code outside module families may import modules only from the CLI composition root through exact registrar packages")
|
||||
}
|
||||
|
||||
type moduleImportTarget struct {
|
||||
@@ -404,6 +445,15 @@ func isBlackBoxIntegrationTest(filename string, sourcePackage string) bool {
|
||||
return isIntegrationFile(filename) && strings.HasSuffix(filename, "_test.go") && sourcePackage == "integration_test"
|
||||
}
|
||||
|
||||
func isCompatibilityTestFile(filename string) bool {
|
||||
if !strings.HasSuffix(filename, "_test.go") {
|
||||
return false
|
||||
}
|
||||
return strings.HasPrefix(filename, "internal/cli/") ||
|
||||
strings.HasPrefix(filename, "internal/core/") ||
|
||||
strings.HasPrefix(filename, "internal/framework/")
|
||||
}
|
||||
|
||||
func testRepositoryRoot(t *testing.T) string {
|
||||
t.Helper()
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
|
||||
@@ -293,6 +293,9 @@ func (seriatimArtifactCodec) Schema() contracts.ArtifactSchema {
|
||||
return contracts.ArtifactSchema{ID: "fake.event", Name: "fake_event", Version: "v1", JSONSchema: []byte(`{"type":"object"}`)}
|
||||
}
|
||||
func (seriatimArtifactCodec) MediaType() string { return "application/json" }
|
||||
func (seriatimArtifactCodec) EncodeCandidate(value seriatimArtifact) ([]byte, error) {
|
||||
return json.Marshal(value)
|
||||
}
|
||||
func (seriatimArtifactCodec) Encode(value seriatimArtifact) ([]byte, error) {
|
||||
return json.Marshal(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user