From b3ed21b6a3e992cdfb87cd882b0aa8521e3c0725 Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 26 Mar 2026 01:46:25 +0000 Subject: [PATCH] =?UTF-8?q?wip:=20test=20dogfooding=20=E2=80=94=20dispatch?= =?UTF-8?q?=5Ftest.go=20json.Marshal=E2=86=92core.JSONMarshalString?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial migration of dispatch_test.go: 5 of 9 json.Marshal+os.WriteFile pairs replaced with fs.Write+core.JSONMarshalString. Pattern established for remaining 74 calls across 30 test files. Co-Authored-By: Virgil --- pkg/agentic/dispatch_test.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/agentic/dispatch_test.go b/pkg/agentic/dispatch_test.go index 00300e3..f760b32 100644 --- a/pkg/agentic/dispatch_test.go +++ b/pkg/agentic/dispatch_test.go @@ -134,8 +134,7 @@ func TestDispatch_StartIssueTracking_Good(t *testing.T) { dir := t.TempDir() st := &WorkspaceStatus{Status: "running", Repo: "go-io", Org: "core", Issue: 15} - data, _ := json.Marshal(st) - os.WriteFile(core.JoinPath(dir, "status.json"), data, 0o644) + fs.Write(core.JoinPath(dir, "status.json"), core.JSONMarshalString(st)) s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}), forge: forge.NewForge(srv.URL, "tok"), backoff: make(map[string]time.Time), failCount: make(map[string]int)} s.startIssueTracking(dir) @@ -155,8 +154,7 @@ func TestDispatch_StartIssueTracking_Ugly(t *testing.T) { // Status has no issue — early return dir := t.TempDir() st := &WorkspaceStatus{Status: "running", Repo: "test"} - data, _ := json.Marshal(st) - os.WriteFile(core.JoinPath(dir, "status.json"), data, 0o644) + fs.Write(core.JoinPath(dir, "status.json"), core.JSONMarshalString(st)) s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}), forge: forge.NewForge("http://invalid", "tok"), backoff: make(map[string]time.Time), failCount: make(map[string]int)} s.startIssueTracking(dir) // no issue → skips API call @@ -172,8 +170,7 @@ func TestDispatch_StopIssueTracking_Good(t *testing.T) { dir := t.TempDir() st := &WorkspaceStatus{Status: "completed", Repo: "go-io", Issue: 10} - data, _ := json.Marshal(st) - os.WriteFile(core.JoinPath(dir, "status.json"), data, 0o644) + fs.Write(core.JoinPath(dir, "status.json"), core.JSONMarshalString(st)) s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}), forge: forge.NewForge(srv.URL, "tok"), backoff: make(map[string]time.Time), failCount: make(map[string]int)} s.stopIssueTracking(dir) @@ -188,8 +185,7 @@ func TestDispatch_StopIssueTracking_Ugly(t *testing.T) { // Status has no issue dir := t.TempDir() st := &WorkspaceStatus{Status: "completed", Repo: "test"} - data, _ := json.Marshal(st) - os.WriteFile(core.JoinPath(dir, "status.json"), data, 0o644) + fs.Write(core.JoinPath(dir, "status.json"), core.JSONMarshalString(st)) s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}), forge: forge.NewForge("http://invalid", "tok"), backoff: make(map[string]time.Time), failCount: make(map[string]int)} s.stopIssueTracking(dir) @@ -202,9 +198,8 @@ func TestDispatch_BroadcastStart_Good(t *testing.T) { t.Setenv("CORE_WORKSPACE", root) wsDir := core.JoinPath(root, "workspace", "ws-test") - os.MkdirAll(wsDir, 0o755) - data, _ := json.Marshal(WorkspaceStatus{Repo: "go-io", Agent: "codex"}) - os.WriteFile(core.JoinPath(wsDir, "status.json"), data, 0o644) + fs.EnsureDir(wsDir) + fs.Write(core.JoinPath(wsDir, "status.json"), core.JSONMarshalString(WorkspaceStatus{Repo: "go-io", Agent: "codex"})) c := core.New() s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(c, AgentOptions{}), backoff: make(map[string]time.Time), failCount: make(map[string]int)}