package main import ( "errors" "testing" "github.com/kami/maven/internal/config" "github.com/kami/maven/internal/ipc" "github.com/kami/maven/internal/speaker" ) // "enabled": true with no model_path used to wire all three methods and log // "enrolment on". Nothing behind them works without an embedder, so the // capability stays off and the socket answers "no such method". func TestSpeakerStaysOffWithoutAModelPath(t *testing.T) { srv := &ipc.Server{} cfg := &config.Config{Speaker: &config.SpeakerConfig{Enabled: true}} wireSpeaker(srv, nil, cfg) if srv.EnrollSpeakerFn != nil || srv.ListSpeakersFn != nil || srv.ForgetSpeakerFn != nil { t.Error("speaker methods were wired with nothing to embed with") } } // The gate is Recognizes(), so a disabled block with a model path is off too. func TestSpeakerStaysOffWhenDisabled(t *testing.T) { srv := &ipc.Server{} cfg := &config.Config{Speaker: &config.SpeakerConfig{ModelPath: "/nope/ecapa.onnx"}} wireSpeaker(srv, nil, cfg) if srv.EnrollSpeakerFn != nil { t.Error("speaker methods were wired for a disabled block") } } // ErrDisabled is "this capability is off", not "core broke". It used to fall // through speakerErr's default and reach the surface as an opaque failure. func TestSpeakerErrMapsDisabledToUnknownMethod(t *testing.T) { if got := speakerErr(speaker.ErrDisabled); !errors.Is(got, ipc.ErrUnknownMethod) { t.Errorf("speakerErr(ErrDisabled) = %v, want ErrUnknownMethod", got) } if got := speakerErr(speaker.ErrNotFound); !errors.Is(got, ipc.ErrNoFact) { t.Errorf("speakerErr(ErrNotFound) = %v, want ErrNoFact", got) } if got := speakerErr(nil); got != nil { t.Errorf("speakerErr(nil) = %v", got) } }