thread-master/backend/internal/model/threads_account/usecase/connection_prefs_test.go

47 lines
1.3 KiB
Go

package usecase
import (
"testing"
domusecase "haixun-backend/internal/model/threads_account/domain/usecase"
)
func TestApplyConnectionPatchSearchSourceInDevMode(t *testing.T) {
current := deriveConnectionPrefsFromDevMode(true)
patch := domusecase.ConnectionPrefsPatch{
SearchSourceMode: strPtr("brave"),
}
next := applyConnectionPatch(current, patch)
if next.SearchSourceMode != "brave" {
t.Fatalf("expected brave, got %s", next.SearchSourceMode)
}
if !next.DevMode {
t.Fatal("expected dev mode to stay enabled")
}
}
func TestApplyConnectionPatchSearchSourceInFormalMode(t *testing.T) {
current := deriveConnectionPrefsFromDevMode(false)
patch := domusecase.ConnectionPrefsPatch{
SearchSourceMode: strPtr("threads_crawler"),
}
next := applyConnectionPatch(current, patch)
if next.SearchSourceMode != "threads_crawler" {
t.Fatalf("expected threads_crawler, got %s", next.SearchSourceMode)
}
}
func TestNormalizeConnectionPrefsKeepsCrawlerModeInFormalMode(t *testing.T) {
prefs := domusecase.ConnectionPrefs{
DevMode: false,
SearchSourceMode: "crawler",
}
next := normalizeConnectionPrefs(prefs)
if next.SearchSourceMode != "crawler" {
t.Fatalf("expected crawler, got %s", next.SearchSourceMode)
}
}
func strPtr(v string) *string {
return &v
}