Compose production modules through family registrars
This commit is contained in:
22
internal/modules/seriatim/register/register.go
Normal file
22
internal/modules/seriatim/register/register.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Package register composes the production Seriatim module family.
|
||||
package register
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/input/seriatim"
|
||||
)
|
||||
|
||||
// Register adds all production Seriatim modules.
|
||||
func Register(registries pipeline.Registries, assets *llm.AssetRegistry) error {
|
||||
_ = assets
|
||||
if registries.Inputs == nil {
|
||||
return fmt.Errorf("seriatim registrar: input registry must not be nil")
|
||||
}
|
||||
if err := seriatim.Register(registries.Inputs); err != nil {
|
||||
return fmt.Errorf("register transcript input: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
37
internal/modules/seriatim/register/register_test.go
Normal file
37
internal/modules/seriatim/register/register_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
)
|
||||
|
||||
func TestRegisterAddsSeriatimFamily(t *testing.T) {
|
||||
registries := pipeline.Registries{Inputs: pipeline.NewInputAdapterRegistry()}
|
||||
if err := Register(registries, nil); err != nil {
|
||||
t.Fatalf("Register() error = %v, want nil", err)
|
||||
}
|
||||
if got, want := registries.Inputs.RegisteredKeys(), []string{"seriatim"}; !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("input keys = %#v, want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterRejectsNilInputRegistry(t *testing.T) {
|
||||
err := Register(pipeline.Registries{}, nil)
|
||||
if err == nil || !strings.Contains(err.Error(), "input registry must not be nil") {
|
||||
t.Fatalf("Register() error = %v, want nil input registry error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterReportsDuplicateSeriatimRegistration(t *testing.T) {
|
||||
registries := pipeline.Registries{Inputs: pipeline.NewInputAdapterRegistry()}
|
||||
if err := Register(registries, nil); err != nil {
|
||||
t.Fatalf("first Register() error = %v, want nil", err)
|
||||
}
|
||||
err := Register(registries, nil)
|
||||
if err == nil || !strings.Contains(err.Error(), "register transcript input") || !strings.Contains(err.Error(), "already registered") {
|
||||
t.Fatalf("second Register() error = %v, want contextual duplicate error", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user