# test: route the corecmd stub handlers through printJSON

`1febc7e`→[main](/content/gh/entireio/cli/commits/main/index.html)·

Soph·1w ago·2 files·+3 added/-3 removed

PR #1626 landed corecmd_list_test.go / corecmd_mutation_test.go calling a
writeJSON helper, green against a base that predated #1606 — which
deleted writeJSON to standardize package cli on printJSON. #1626 merged
two days later without a re-run against the moved base, so main's Lint
typecheck and Tests are red and every open PR inherits the failure
via the merge preview.

Point the three call sites at printJSON, the same conversion #1606
applied to the other test fixtures (repo_mirror_test.go,
resolveref_test.go, ...), rather than reintroducing the deleted
duplicate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

## Sessions

d541b17e10f8View transcript

### Changes

- cmd/entire/cli

- Mcorecmd_list_test.go +1/-1

- Mcorecmd_mutation_test.go +2/-2

```
17 unmodified lines

18
19
20
21
21
22
23
24

17 unmodified lines

srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		assert.Equal(t, http.MethodGet, r.Method)
		w.Header().Set("Content-Type", "application/json")
		if err := writeJSON(w, &coreapi.ListOrgsOutputBody{Orgs: orgs}); err != nil {
		if err := printJSON(w, &coreapi.ListOrgsOutputBody{Orgs: orgs}); err != nil {
			t.Errorf("encode orgs: %v", err)
		}
		}
	}))
```

Mcmd/entire/cli/corecmd_list_test.go +1/-1

```
19 unmodified lines

20
21
22
23
23
24
25
26
44 unmodified lines

71
72
73
74
74
75
76
77

19 unmodified lines

assert.Equal(t, http.MethodPost, r.Method)
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusCreated)
		if err := writeJSON(w, &coreapi.Org{ID: testDeleteULID, Name: "acme", Region: "us"}); err != nil {
		if err := printJSON(w, &coreapi.Org{ID: testDeleteULID, Name: "acme", Region: "us"}); err != nil {
			t.Errorf("encode org: %v", err)
		}
		}
	}))
44 unmodified lines

ClusterHost:     coreapi.NewOptString("c.example.com"),
			Path:            coreapi.NewOptString("/gh/o/web"),
		}
		if err := writeJSON(w, repo); err != nil {
		if err := printJSON(w, repo); err != nil {
			t.Errorf("encode repo: %v", err)
		}
		}
	}))
```

Mcmd/entire/cli/corecmd_mutation_test.go +2/-2
