Files
geo/server/internal/tenant/app/question_combination_fill_test.go
T

33 lines
1004 B
Go
Raw Normal View History

package app
import (
"reflect"
"testing"
)
func TestQuestionCombinationRegionTermsFromIPRegion(t *testing.T) {
got := questionCombinationRegionTermsFromIPRegion("中国|0|安徽省|合肥市|电信")
want := []string{"合肥", "华东"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("region terms = %#v, want %#v", got, want)
}
}
func TestBuildQuestionCombinationFillFallback(t *testing.T) {
description := "GEO 与 AI 搜索优化平台"
got := buildQuestionCombinationFillFallback(&questionBrandContext{
BrandName: "GeoRankly",
Description: &description,
}, []string{"上海", "华东"}, QuestionCombinationFillRequest{})
if !reflect.DeepEqual(got.Region, []string{"上海", "华东"}) {
t.Fatalf("region = %#v", got.Region)
}
if len(got.Core) < 3 || got.Core[0] != "GEO" {
t.Fatalf("core fallback = %#v", got.Core)
}
if len(got.Prefix) != 4 || len(got.Industry) != 4 || len(got.Suffix) != 4 {
t.Fatalf("expected four hot terms for non-region columns, got %#v", got)
}
}