Complete Phase 14 homophones module
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/contracts"
|
||||
glossarymodule "gitea.maximumdirect.net/eric/audita/internal/modules/glossary"
|
||||
grammarmodule "gitea.maximumdirect.net/eric/audita/internal/modules/grammar"
|
||||
homophonesmodule "gitea.maximumdirect.net/eric/audita/internal/modules/homophones"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -72,6 +73,7 @@ func NewFactory(deps Dependencies) *Factory {
|
||||
constructors: make(map[string]Constructor, len(knownModuleKeys)),
|
||||
}
|
||||
_ = factory.RegisterConstructor(ModuleKeyGlossary, constructGlossaryModule)
|
||||
_ = factory.RegisterConstructor(ModuleKeyHomophones, constructHomophonesModule)
|
||||
_ = factory.RegisterConstructor(ModuleKeyGrammar, constructGrammarModule)
|
||||
return factory
|
||||
}
|
||||
@@ -104,6 +106,12 @@ func constructGlossaryModule(ctx context.Context, req ConstructRequest) (contrac
|
||||
return glossarymodule.New()
|
||||
}
|
||||
|
||||
func constructHomophonesModule(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
|
||||
_ = ctx
|
||||
_ = req
|
||||
return homophonesmodule.New()
|
||||
}
|
||||
|
||||
// ModuleForSpec resolves one configured run spec into a module instance.
|
||||
func (f *Factory) ModuleForSpec(spec contracts.ModuleRunSpec) (contracts.TranscriptModule, error) {
|
||||
if f == nil {
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestUnsupportedUnknownModuleKeyFailsCleanly(t *testing.T) {
|
||||
|
||||
func TestRecognizedButUnimplementedModuleKeyFailsCleanly(t *testing.T) {
|
||||
factory := NewFactory(Dependencies{})
|
||||
for _, key := range []string{ModuleKeyHomophones, ModuleKeySpokenWord} {
|
||||
for _, key := range []string{ModuleKeySpokenWord} {
|
||||
t.Run(key, func(t *testing.T) {
|
||||
_, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: key, InstanceName: key})
|
||||
if err == nil {
|
||||
@@ -106,6 +106,17 @@ func TestGlossaryIsRegisteredAndConstructibleByDefault(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomophonesIsRegisteredAndConstructibleByDefault(t *testing.T) {
|
||||
factory := NewFactory(Dependencies{})
|
||||
module, err := factory.ModuleForSpec(contracts.ModuleRunSpec{ModuleKey: ModuleKeyHomophones, InstanceName: ModuleKeyHomophones})
|
||||
if err != nil {
|
||||
t.Fatalf("ModuleForSpec error: %v", err)
|
||||
}
|
||||
if module.Key() != ModuleKeyHomophones {
|
||||
t.Fatalf("expected homophones module key, got %q", module.Key())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterConstructorAndConstruct(t *testing.T) {
|
||||
factory := NewFactory(Dependencies{})
|
||||
if err := factory.RegisterConstructor(ModuleKeyGlossary, func(ctx context.Context, req ConstructRequest) (contracts.TranscriptModule, error) {
|
||||
|
||||
Reference in New Issue
Block a user