2026-08-05 19:13:37 +00:00
package locationregistry
2026-08-04 00:02:18 +00:00
import (
"reflect"
"strings"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
)
2026-11-22 00:50:54 +00:00
func TestModuleRegistrationAndNativeDependencies ( t * testing . T ) {
if _ , err := New ( nil , Options { } ) ; err == nil || ! strings . Contains ( err . Error ( ) , "native engine" ) {
2026-08-04 00:02:18 +00:00
t . Fatalf ( "New(nil) error = %v, want client rejection" , err )
}
2026-11-22 00:50:54 +00:00
if _ , err := New ( newExtractor ( t , & fakeLocationsLLMClient { } ) . engine , Options { } , contracts . ReferenceSet { } , contracts . ReferenceSet { } ) ; err == nil || ! strings . Contains ( err . Error ( ) , "at most one" ) {
2026-08-04 00:02:18 +00:00
t . Fatalf ( "New() error = %v, want reference-set rejection" , err )
}
2026-11-22 00:50:54 +00:00
want := pipeline . ModuleSpec { Key : Key , Stage : pipeline . StageExtract , ExecutionClass : contracts . ExecutionClassLLMBacked , Prompts : [ ] string { PromptID , CorrectionPromptID } , Requires : [ ] string { "chunks" , "source.transcript" } , Provides : [ ] string { "dnd.location_registry" } , ArtifactKind : dnd . LocationRegistryKind , ReferenceSlots : referenceSlots ( ) }
2026-08-04 00:02:18 +00:00
if got := ModuleSpec ( ) ; ! reflect . DeepEqual ( got , want ) {
t . Fatalf ( "ModuleSpec() = %#v, want %#v" , got , want )
}
registry := pipeline . NewExtractorRegistry ( )
if err := Register ( registry ) ; err != nil {
t . Fatalf ( "Register() error = %v" , err )
}
if got , ok := registry . Spec ( Key ) ; ! ok || ! reflect . DeepEqual ( got , want ) {
t . Fatalf ( "registry spec = %#v, present = %t" , got , ok )
}
if err := Register ( nil ) ; err == nil || ! strings . Contains ( err . Error ( ) , "extractor registry" ) {
t . Fatalf ( "Register(nil) error = %v, want registry rejection" , err )
}
if _ , err := DecodeOptions ( map [ string ] any { "unknown" : true } ) ; err == nil {
t . Fatal ( "DecodeOptions() accepted unknown option" )
}
2026-11-22 00:50:54 +00:00
2026-08-04 00:02:18 +00:00
}