2026-06-27 14:49:17 +00:00
|
|
|
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
|
2026-06-28 08:28:42 +00:00
|
|
|
}
|