Require explicit module execution classes
This commit is contained in:
@@ -101,10 +101,11 @@ func runRegistryBehaviorTests[M any](t *testing.T, testCase registryBehaviorCase
|
||||
t.Run(testCase.name+"/metadata registration and lookup", func(t *testing.T) {
|
||||
registry := testCase.newRegistry()
|
||||
spec := ModuleSpec{
|
||||
Key: " " + testCase.key + " ",
|
||||
Stage: testCase.stage,
|
||||
Provides: []string{" beta ", "alpha", "", "beta"},
|
||||
Requires: []string{" source ", "source", ""},
|
||||
Key: " " + testCase.key + " ",
|
||||
Stage: testCase.stage,
|
||||
ExecutionClass: contracts.ExecutionClassDeterministic,
|
||||
Provides: []string{" beta ", "alpha", "", "beta"},
|
||||
Requires: []string{" source ", "source", ""},
|
||||
}
|
||||
if err := testCase.registerWithSpec(registry, spec, testCase.constructor(testCase.key)); err != nil {
|
||||
t.Fatalf("RegisterWithSpec() error = %v, want nil", err)
|
||||
@@ -153,7 +154,7 @@ func runRegistryBehaviorTests[M any](t *testing.T, testCase registryBehaviorCase
|
||||
|
||||
t.Run(testCase.name+"/wrong stage rejection", func(t *testing.T) {
|
||||
registry := testCase.newRegistry()
|
||||
err := testCase.registerWithSpec(registry, ModuleSpec{Key: testCase.key, Stage: testCase.wrongStage}, testCase.constructor(testCase.key))
|
||||
err := testCase.registerWithSpec(registry, ModuleSpec{Key: testCase.key, Stage: testCase.wrongStage, ExecutionClass: contracts.ExecutionClassDeterministic}, testCase.constructor(testCase.key))
|
||||
if err == nil {
|
||||
t.Fatal("RegisterWithSpec() error = nil, want error")
|
||||
}
|
||||
@@ -162,6 +163,22 @@ func runRegistryBehaviorTests[M any](t *testing.T, testCase registryBehaviorCase
|
||||
}
|
||||
})
|
||||
|
||||
t.Run(testCase.name+"/execution class rejection", func(t *testing.T) {
|
||||
for _, spec := range []ModuleSpec{
|
||||
{Key: testCase.key, Stage: testCase.stage},
|
||||
{Key: testCase.key, Stage: testCase.stage, ExecutionClass: contracts.ExecutionClass("unsupported")},
|
||||
} {
|
||||
registry := testCase.newRegistry()
|
||||
err := testCase.registerWithSpec(registry, spec, testCase.constructor(testCase.key))
|
||||
if err == nil {
|
||||
t.Fatal("RegisterWithSpec() error = nil, want execution class error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "execution class") {
|
||||
t.Fatalf("RegisterWithSpec() error = %q, want execution class error", err.Error())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run(testCase.name+"/key trimming", func(t *testing.T) {
|
||||
registry := testCase.newRegistry()
|
||||
if err := testCase.register(registry, " "+testCase.key+" ", testCase.constructor(testCase.key)); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user