60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package metadata
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/audita/internal/framework/contracts"
|
|
frameworkvalidators "gitea.maximumdirect.net/eric/audita/internal/framework/validators"
|
|
)
|
|
|
|
type unclassifiedValidator struct{}
|
|
|
|
func (u unclassifiedValidator) Name() string { return "unclassified" }
|
|
|
|
func (u unclassifiedValidator) Validate(_ context.Context, _ contracts.ValidationRequest) (frameworkvalidators.Result, error) {
|
|
return frameworkvalidators.Result{ValidatorName: u.Name(), Decisions: nil}, nil
|
|
}
|
|
|
|
type namedUnclassifiedValidator struct {
|
|
name string
|
|
}
|
|
|
|
func (n namedUnclassifiedValidator) Name() string { return n.name }
|
|
|
|
func (n namedUnclassifiedValidator) Validate(_ context.Context, _ contracts.ValidationRequest) (frameworkvalidators.Result, error) {
|
|
return frameworkvalidators.Result{ValidatorName: n.Name(), Decisions: nil}, nil
|
|
}
|
|
|
|
func TestClassOfDefaultsToDeterministic(t *testing.T) {
|
|
if got := ClassOf(unclassifiedValidator{}); got != ExecutionClassDeterministic {
|
|
t.Fatalf("expected deterministic default class, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestWrapExposesExecutionClass(t *testing.T) {
|
|
wrapped := Wrap(unclassifiedValidator{}, ExecutionClassLLMBacked)
|
|
if got := ClassOf(wrapped); got != ExecutionClassLLMBacked {
|
|
t.Fatalf("expected llm_backed class, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestClassForKey(t *testing.T) {
|
|
if got := ClassForKey(KeyProposalShape); got != ExecutionClassDeterministic {
|
|
t.Fatalf("expected deterministic class for %q, got %q", KeyProposalShape, got)
|
|
}
|
|
if got := ClassForKey(KeySpokenFormPlausibility); got != ExecutionClassLLMBacked {
|
|
t.Fatalf("expected llm_backed class for %q, got %q", KeySpokenFormPlausibility, got)
|
|
}
|
|
if got := ClassForKey("unknown"); got != ExecutionClassDeterministic {
|
|
t.Fatalf("expected deterministic fallback for unknown key, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestClassOfFallsBackToStableValidatorKey(t *testing.T) {
|
|
v := namedUnclassifiedValidator{name: KeyEditorialReview}
|
|
if got := ClassOf(v); got != ExecutionClassLLMBacked {
|
|
t.Fatalf("expected llm_backed fallback by key, got %q", got)
|
|
}
|
|
}
|