41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package alwaysaccept
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
|
)
|
|
|
|
func TestValidatorApproves(t *testing.T) {
|
|
result, err := New().Validate(context.Background(), contracts.ValidationRequest{})
|
|
if err != nil {
|
|
t.Fatalf("Validate() error = %v, want nil", err)
|
|
}
|
|
if !result.Approved {
|
|
t.Fatalf("Approved = false, want true")
|
|
}
|
|
if result.ReasonCode != "" || result.Message != "" {
|
|
t.Fatalf("result = %#v, want approval without rejection details", result)
|
|
}
|
|
}
|
|
|
|
func TestSpecAndRegister(t *testing.T) {
|
|
if Spec().Key != Key || Spec().ExecutionClass != contracts.ExecutionClassDeterministic {
|
|
t.Fatalf("Spec() = %#v, want key and deterministic execution", Spec())
|
|
}
|
|
|
|
registry := pipeline.NewValidatorRegistry()
|
|
if err := Register(registry); err != nil {
|
|
t.Fatalf("Register() error = %v, want nil", err)
|
|
}
|
|
validator, err := registry.Build(Key)
|
|
if err != nil {
|
|
t.Fatalf("Build(%q) error = %v, want nil", Key, err)
|
|
}
|
|
if validator.Name() != Key {
|
|
t.Fatalf("Name() = %q, want %q", validator.Name(), Key)
|
|
}
|
|
}
|