Files
Memoh/internal/conversation/flow/resolver_model_selection_test.go
T

91 lines
2.0 KiB
Go

package flow
import (
"testing"
"github.com/memohai/memoh/internal/models"
)
func TestMatchesModelReference_ModelID(t *testing.T) {
t.Parallel()
model := models.GetResponse{
ID: "a55f0d2d-1547-49a0-b085-ec4ab778f4b8",
ModelID: "gpt-4o",
}
if !matchesModelReference(model, "gpt-4o") {
t.Fatal("expected model slug to match")
}
}
func TestMatchesModelReference_UUID(t *testing.T) {
t.Parallel()
model := models.GetResponse{
ID: "a55f0d2d-1547-49a0-b085-ec4ab778f4b8",
ModelID: "gpt-4o",
}
if !matchesModelReference(model, "a55f0d2d-1547-49a0-b085-ec4ab778f4b8") {
t.Fatal("expected model UUID to match")
}
}
func TestMatchesModelReference_NoMatch(t *testing.T) {
t.Parallel()
model := models.GetResponse{
ID: "a55f0d2d-1547-49a0-b085-ec4ab778f4b8",
ModelID: "gpt-4o",
}
if matchesModelReference(model, "gpt-4.1") {
t.Fatal("expected non-matching model reference to fail")
}
}
func TestMatchesModelReference_TrimmedInput(t *testing.T) {
t.Parallel()
model := models.GetResponse{
ID: "a55f0d2d-1547-49a0-b085-ec4ab778f4b8",
ModelID: "gpt-4o",
}
if !matchesModelReference(model, " gpt-4o ") {
t.Fatal("expected trimmed model slug to match")
}
}
func TestBuildModelSelectionRequest_PreservesOverrides(t *testing.T) {
t.Parallel()
req := buildModelSelectionRequest(baseRunConfigParams{
BotID: "bot-1",
SessionID: "session-1",
CurrentPlatform: "web",
Model: "model-override",
Provider: "openai-responses",
}, "chat-1")
if req.BotID != "bot-1" {
t.Fatalf("unexpected bot id: %q", req.BotID)
}
if req.ChatID != "chat-1" {
t.Fatalf("unexpected chat id: %q", req.ChatID)
}
if req.SessionID != "session-1" {
t.Fatalf("unexpected session id: %q", req.SessionID)
}
if req.CurrentChannel != "web" {
t.Fatalf("unexpected current channel: %q", req.CurrentChannel)
}
if req.Model != "model-override" {
t.Fatalf("unexpected model override: %q", req.Model)
}
if req.Provider != "openai-responses" {
t.Fatalf("unexpected provider override: %q", req.Provider)
}
}