Files
Memoh/internal/channel/manager_test.go
T
BBQ 29e6ddd1f9 refactor: replace global channel registry with instance-based Registry and interface-driven adapters
- Replace global channelRegistry singleton with explicit *Registry passed via dependency injection
- Split monolithic manager.go into connection.go (lifecycle), inbound.go (dispatch), outbound.go (pipeline)
- Introduce optional adapter interfaces: ConfigNormalizer, TargetResolver, BindingMatcher
- Move Descriptor() to Adapter interface, remove init()-based registration
- Relocate SessionHub to adapters/local package
- Extract shared UUID/time helpers to internal/db/uuid.go
- Decompose ConfigStore into fine-grained interfaces: ConfigLister, ConfigResolver, BindingStore, SessionStore
2026-02-06 23:47:12 +08:00

33 lines
686 B
Go

package channel_test
import (
"testing"
"github.com/memohai/memoh/internal/channel"
)
func TestResolveTargetFromUserConfig(t *testing.T) {
t.Parallel()
reg := newTestConfigRegistry()
target, err := reg.ResolveTargetFromUserConfig(testChannelType, map[string]any{
"target": "alice",
})
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
if target != "resolved:alice" {
t.Fatalf("unexpected target: %s", target)
}
}
func TestResolveTargetFromUserConfigUnsupported(t *testing.T) {
t.Parallel()
reg := channel.NewRegistry()
_, err := reg.ResolveTargetFromUserConfig("unknown", map[string]any{})
if err == nil {
t.Fatalf("expected error, got nil")
}
}