//go:build llm_script package main import ( "os" "path/filepath" "strings" "testing" "time" ) func TestRunDeepSeekNewsSignatureGuardInitializesBaseline(t *testing.T) { tempDir := t.TempDir() baselinePath := filepath.Join(tempDir, "baseline.signature.json") result, err := runDeepSeekNewsSignatureGuard(deepseekNewsSignatureGuardConfig{ URL: defaultDeepSeekNewsFetchURL, Fixture: filepath.Join("testdata", "intraday_verification_official_release.html"), SnapshotDir: tempDir, BaselinePath: baselinePath, Timeout: time.Second, AllowBootstrap: true, }, time.Date(2026, 5, 27, 21, 0, 0, 0, time.FixedZone("CST", 8*3600))) if err != nil { t.Fatalf("runDeepSeekNewsSignatureGuard 返回错误: %v", err) } if !result.BaselineInitialized { t.Fatal("期望初始化 baseline") } if _, err := os.Stat(baselinePath); err != nil { t.Fatalf("baseline 未写入: %v", err) } } func TestRunDeepSeekNewsSignatureGuardDetectsDrift(t *testing.T) { tempDir := t.TempDir() baselinePath := filepath.Join(tempDir, "baseline.signature.json") _, err := runDeepSeekNewsSignatureGuard(deepseekNewsSignatureGuardConfig{ URL: defaultDeepSeekNewsFetchURL, Fixture: filepath.Join("testdata", "intraday_verification_official_release.html"), SnapshotDir: tempDir, BaselinePath: baselinePath, Timeout: time.Second, AllowBootstrap: true, }, time.Date(2026, 5, 27, 21, 1, 0, 0, time.FixedZone("CST", 8*3600))) if err != nil { t.Fatalf("初始化 baseline 失败: %v", err) } driftFixture := filepath.Join(tempDir, "drift.html") if err := os.WriteFile(driftFixture, []byte("