Verify the reliability sprint and guard release checkout validation
This commit is contained in:
@@ -9,104 +9,33 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/proposals"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/editorial_review"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/meaning_reversal_review"
|
||||
validatormetadata "gitea.maximumdirect.net/eric/audita/v3/internal/validators/metadata"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/no_effect"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/non_empty_resulting_segment"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/original_text_presence"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/proposal_shape"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/protected_terms"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/validators/spoken_form_plausibility"
|
||||
)
|
||||
|
||||
func TestBuiltInRegistryRegistersAllKeys(t *testing.T) {
|
||||
r := NewBuiltInRegistry()
|
||||
for _, key := range []string{
|
||||
KeyProposalShape,
|
||||
KeyOriginalTextPresence,
|
||||
KeyNonEmptyResultingSegment,
|
||||
KeyNoEffect,
|
||||
KeyProtectedTerms,
|
||||
KeySpokenFormPlausibility,
|
||||
KeyMeaningReversalReview,
|
||||
KeyEditorialReview,
|
||||
func TestRegisteredValidatorsUseDocumentedRoles(t *testing.T) {
|
||||
registry := NewBuiltInRegistry()
|
||||
for _, tc := range []struct {
|
||||
key string
|
||||
role validatormetadata.ExecutionClass
|
||||
}{
|
||||
{KeyProposalShape, validatormetadata.ExecutionClassDeterministic},
|
||||
{KeyOriginalTextPresence, validatormetadata.ExecutionClassDeterministic},
|
||||
{KeyNonEmptyResultingSegment, validatormetadata.ExecutionClassDeterministic},
|
||||
{KeyNoEffect, validatormetadata.ExecutionClassDeterministic},
|
||||
{KeyProtectedTerms, validatormetadata.ExecutionClassDeterministic},
|
||||
{KeySpokenFormPlausibility, validatormetadata.ExecutionClassLLMBacked},
|
||||
{KeyMeaningReversalReview, validatormetadata.ExecutionClassLLMBacked},
|
||||
{KeyEditorialReview, validatormetadata.ExecutionClassLLMBacked},
|
||||
} {
|
||||
def, ok := r.Lookup(key)
|
||||
if !ok {
|
||||
t.Fatalf("expected validator key %q to be registered", key)
|
||||
}
|
||||
v, err := def.Build()
|
||||
if err != nil {
|
||||
t.Fatalf("build validator %q: %v", key, err)
|
||||
}
|
||||
if v.Name() != key {
|
||||
t.Fatalf("expected validator name %q, got %q", key, v.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuiltInValidatorPackagesConstruct(t *testing.T) {
|
||||
type validatorCtor struct {
|
||||
name string
|
||||
key string
|
||||
build func() (frameworkvalidators.Validator, error)
|
||||
wantClass validatormetadata.ExecutionClass
|
||||
}
|
||||
cases := []validatorCtor{
|
||||
{name: "proposal_shape", key: KeyProposalShape, build: proposal_shape.New, wantClass: validatormetadata.ExecutionClassDeterministic},
|
||||
{name: "original_text_presence", key: KeyOriginalTextPresence, build: original_text_presence.New, wantClass: validatormetadata.ExecutionClassDeterministic},
|
||||
{name: "non_empty_resulting_segment", key: KeyNonEmptyResultingSegment, build: non_empty_resulting_segment.New, wantClass: validatormetadata.ExecutionClassDeterministic},
|
||||
{name: "no_effect", key: KeyNoEffect, build: no_effect.New, wantClass: validatormetadata.ExecutionClassDeterministic},
|
||||
{name: "protected_terms", key: KeyProtectedTerms, build: protected_terms.New, wantClass: validatormetadata.ExecutionClassDeterministic},
|
||||
{name: "spoken_form_plausibility", key: KeySpokenFormPlausibility, build: spoken_form_plausibility.New, wantClass: validatormetadata.ExecutionClassLLMBacked},
|
||||
{name: "meaning_reversal_review", key: KeyMeaningReversalReview, build: meaning_reversal_review.New, wantClass: validatormetadata.ExecutionClassLLMBacked},
|
||||
{name: "editorial_review", key: KeyEditorialReview, build: editorial_review.New, wantClass: validatormetadata.ExecutionClassLLMBacked},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
v, err := tc.build()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: build: %v", tc.name, err)
|
||||
}
|
||||
if v.Name() != tc.key {
|
||||
t.Fatalf("%s: expected key %q, got %q", tc.name, tc.key, v.Name())
|
||||
}
|
||||
if got := validatormetadata.ClassOf(v); got != tc.wantClass {
|
||||
t.Fatalf("%s: expected class %q, got %q", tc.name, tc.wantClass, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistryBuildsClassifiedValidators(t *testing.T) {
|
||||
r := NewBuiltInRegistry()
|
||||
for _, key := range r.RegisteredKeys() {
|
||||
v, err := r.MustBuild(key)
|
||||
if err != nil {
|
||||
t.Fatalf("must build %q: %v", key, err)
|
||||
}
|
||||
if _, ok := v.(validatormetadata.ClassifiedValidator); !ok {
|
||||
t.Fatalf("expected built validator %q to expose execution classification metadata", key)
|
||||
}
|
||||
want := validatormetadata.ClassForKey(key)
|
||||
if got := validatormetadata.ClassOf(v); got != want {
|
||||
t.Fatalf("expected class %q for %q, got %q", want, key, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecutionClassResolvableByStableKeyAndByValidatorInstance(t *testing.T) {
|
||||
r := NewBuiltInRegistry()
|
||||
for _, key := range r.RegisteredKeys() {
|
||||
v, err := r.MustBuild(key)
|
||||
if err != nil {
|
||||
t.Fatalf("must build %q: %v", key, err)
|
||||
}
|
||||
fromKey := validatormetadata.ClassForKey(key)
|
||||
fromInstance := validatormetadata.ClassOf(v)
|
||||
if fromInstance != fromKey {
|
||||
t.Fatalf("class mismatch for %q: key=%q instance=%q", key, fromKey, fromInstance)
|
||||
}
|
||||
t.Run(tc.key, func(t *testing.T) {
|
||||
v, err := registry.MustBuild(tc.key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v.Name() != tc.key || validatormetadata.ClassOf(v) != tc.role {
|
||||
t.Fatalf("registered name=%q role=%q, want %q and %q", v.Name(), validatormetadata.ClassOf(v), tc.key, tc.role)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user