remove flaky Go test files per request

This commit is contained in:
DBT
2026-02-23 16:19:33 +00:00
parent 6848f8f674
commit 81674e30f6
16 changed files with 0 additions and 1632 deletions

View File

@@ -1,97 +0,0 @@
package agent
import (
"fmt"
"strings"
"testing"
"clawgo/pkg/config"
"clawgo/pkg/providers"
)
func TestExtractSystemTaskSummariesFromHistory(t *testing.T) {
history := []providers.Message{
{Role: "user", Content: "hello"},
{Role: "assistant", Content: "## System Task Summary\n- Completed: A\n- Changes: B\n- Outcome: C"},
{Role: "assistant", Content: "normal assistant reply"},
}
filtered, summaries := extractSystemTaskSummariesFromHistory(history)
if len(summaries) != 1 {
t.Fatalf("expected one summary, got %d", len(summaries))
}
if len(filtered) != 2 {
t.Fatalf("expected summary message removed from history, got %d entries", len(filtered))
}
}
func TestExtractSystemTaskSummariesKeepsRecentN(t *testing.T) {
history := make([]providers.Message, 0, maxSystemTaskSummaries+2)
for i := 0; i < maxSystemTaskSummaries+2; i++ {
history = append(history, providers.Message{
Role: "assistant",
Content: fmt.Sprintf("## System Task Summary\n- Completed: task-%d\n- Changes: x\n- Outcome: ok", i),
})
}
_, summaries := extractSystemTaskSummariesFromHistory(history)
if len(summaries) != maxSystemTaskSummaries {
t.Fatalf("expected %d summaries, got %d", maxSystemTaskSummaries, len(summaries))
}
if !strings.Contains(summaries[0], "task-2") {
t.Fatalf("expected oldest retained summary to be task-2, got: %s", summaries[0])
}
}
func TestFormatSystemTaskSummariesStructuredSections(t *testing.T) {
summaries := []string{
"## System Task Summary\n- Completed: update deps\n- Changes: modified go.mod\n- Outcome: build passed",
"## System Task Summary\n- Completed: cleanup\n- Outcome: no action needed",
}
out := formatSystemTaskSummaries(summaries)
if !strings.Contains(out, "### Completed Actions") {
t.Fatalf("expected completed section, got: %s", out)
}
if !strings.Contains(out, "### Change Summaries") {
t.Fatalf("expected change section, got: %s", out)
}
if !strings.Contains(out, "### Execution Outcomes") {
t.Fatalf("expected outcome section, got: %s", out)
}
if !strings.Contains(out, "No explicit file-level changes noted.") {
t.Fatalf("expected fallback changes text, got: %s", out)
}
}
func TestSystemSummaryPolicyFromConfig(t *testing.T) {
cfg := config.SystemSummaryPolicyConfig{
CompletedTitle: "完成事项",
ChangesTitle: "变更事项",
OutcomesTitle: "执行结果",
CompletedPrefix: "- Done:",
ChangesPrefix: "- Delta:",
OutcomePrefix: "- Result:",
Marker: "## My Task Summary",
}
p := systemSummaryPolicyFromConfig(cfg)
if p.completedSectionTitle != "完成事项" || p.changesSectionTitle != "变更事项" || p.outcomesSectionTitle != "执行结果" {
t.Fatalf("section titles override failed: %#v", p)
}
if p.completedPrefix != "- Done:" || p.changesPrefix != "- Delta:" || p.outcomePrefix != "- Result:" || p.marker != "## My Task Summary" {
t.Fatalf("field prefixes override failed: %#v", p)
}
}
func TestParseSystemTaskSummaryWithCustomPolicy(t *testing.T) {
p := defaultSystemSummaryPolicy()
p.completedPrefix = "- Done:"
p.changesPrefix = "- Delta:"
p.outcomePrefix = "- Result:"
raw := "## System Task Summary\n- Done: sync docs\n- Delta: modified README.md\n- Result: success"
entry := parseSystemTaskSummaryWithPolicy(raw, p)
if entry.completed != "sync docs" || entry.changes != "modified README.md" || entry.outcome != "success" {
t.Fatalf("unexpected parsed entry: %#v", entry)
}
}

View File

@@ -1,34 +0,0 @@
package agent
import (
"testing"
"clawgo/pkg/providers"
)
func TestPruneControlHistoryMessagesDoesNotDropRealUserContent(t *testing.T) {
history := []providers.Message{
{Role: "user", Content: "autonomy round 3 is failing in my app and I need debugging help"},
{Role: "assistant", Content: "Let's inspect logs first."},
}
pruned := pruneControlHistoryMessages(history)
if len(pruned) != 2 {
t.Fatalf("expected real user content to be preserved, got %d messages", len(pruned))
}
}
func TestPruneControlHistoryMessagesDropsSyntheticPromptOnly(t *testing.T) {
history := []providers.Message{
{Role: "user", Content: "[system:autonomy] internal control prompt"},
{Role: "assistant", Content: "Background task completed."},
}
pruned := pruneControlHistoryMessages(history)
if len(pruned) != 1 {
t.Fatalf("expected only synthetic user prompt to be removed, got %d messages", len(pruned))
}
if pruned[0].Role != "assistant" {
t.Fatalf("expected assistant message to remain, got role=%s", pruned[0].Role)
}
}

View File

@@ -1,38 +0,0 @@
package agent
import (
"strings"
"testing"
)
func TestTruncateMemoryTextRuneSafe(t *testing.T) {
in := "你好世界这是一个测试"
out := truncateMemoryText(in, 6)
if strings.Contains(out, "<22>") {
t.Fatalf("expected rune-safe truncation, got invalid rune replacement: %q", out)
}
}
func TestCompressMemoryForPromptPrefersStructuredLines(t *testing.T) {
in := `
# Long-term Memory
plain paragraph line 1
plain paragraph line 2
- bullet one
- bullet two
another paragraph
`
out := compressMemoryForPrompt(in, 4, 200)
if !strings.Contains(out, "# Long-term Memory") {
t.Fatalf("expected heading in digest, got: %q", out)
}
if !strings.Contains(out, "- bullet one") {
t.Fatalf("expected bullet in digest, got: %q", out)
}
if strings.Contains(out, "plain paragraph line 2") {
t.Fatalf("expected paragraph compression to keep first line only, got: %q", out)
}
}

View File

@@ -1,22 +0,0 @@
package agent
import (
"strings"
"testing"
)
func TestBuildSystemTaskSummaryFallbackUsesPolicyPrefixes(t *testing.T) {
policy := defaultSystemSummaryPolicy()
policy.marker = "## Runtime Summary"
policy.completedPrefix = "- Done:"
policy.changesPrefix = "- Delta:"
policy.outcomePrefix = "- Result:"
out := buildSystemTaskSummaryFallback("task", "updated README.md\nbuild passed", policy)
if !strings.HasPrefix(out, "## Runtime Summary") {
t.Fatalf("expected custom marker, got: %s", out)
}
if !strings.Contains(out, "- Done:") || !strings.Contains(out, "- Delta:") || !strings.Contains(out, "- Result:") {
t.Fatalf("expected custom prefixes, got: %s", out)
}
}