2026-06-26 08:37:04 +00:00
|
|
|
package viral
|
|
|
|
|
|
2026-06-28 08:28:42 +00:00
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
2026-06-26 08:37:04 +00:00
|
|
|
|
|
|
|
|
func TestExtractUsernames(t *testing.T) {
|
|
|
|
|
blob := `See https://www.threads.net/@creator_one and threads.com/@creator_two/posts/abc`
|
|
|
|
|
got := extractUsernames(blob)
|
|
|
|
|
if len(got) != 2 {
|
|
|
|
|
t.Fatalf("expected 2 usernames, got %d (%v)", len(got), got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIsValidUsernameRejectsReserved(t *testing.T) {
|
|
|
|
|
if isValidUsername("login") {
|
|
|
|
|
t.Fatal("reserved username should be rejected")
|
|
|
|
|
}
|
|
|
|
|
if !isValidUsername("real_creator") {
|
|
|
|
|
t.Fatal("valid username rejected")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-28 08:28:42 +00:00
|
|
|
func TestBuildAccountDiscoverQueriesSingleCombinedQuery(t *testing.T) {
|
|
|
|
|
queries := buildAccountDiscoverQueries("轉職", "想找語錄", []string{"職場語錄", "支柱B"})
|
|
|
|
|
if len(queries) != 1 {
|
|
|
|
|
t.Fatalf("expected 1 combined query, got %d (%v)", len(queries), queries)
|
|
|
|
|
}
|
|
|
|
|
if !strings.Contains(queries[0], `site:threads.net`) || !strings.Contains(queries[0], `"轉職"`) {
|
|
|
|
|
t.Fatalf("unexpected query: %q", queries[0])
|
|
|
|
|
}
|
|
|
|
|
if !strings.Contains(queries[0], "想找語錄") || !strings.Contains(queries[0], `"職場語錄"`) {
|
|
|
|
|
t.Fatalf("brief/pillar hint missing from combined query: %q", queries[0])
|
2026-06-26 08:37:04 +00:00
|
|
|
}
|
|
|
|
|
}
|