refactor(output): share the JSON, created-resource and batch tails

Mutations end with a.jsonResult or a.created instead of hand-rolled
--json branches, the two identical jsonResult/writeMutationJSON helpers
become one, and writeBatchJSON checks --json itself so batch commands
share one tail.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 10:43:46 +02:00
1 parent 27e39ec4be
commit 6b204a34c0
32 files changed
+87 -217

No files matched your search

+6 -2
View File
@@ -379,8 +379,12 @@ func TestMutationFeedback(t *testing.T) {
ref := refLabel("alice/x", 12, "Fix\x1b[2J login")
a.done(cmd, "Created issue %s", ref)
a.warn(cmd, "Issue %s is already closed", ref)
require.NoError(t, a.printURL(cmd, "https://example.org/12"))
require.Equal(t, tc.out, out.String())
require.NoError(t, a.created(cmd, map[string]int{"number": 12}, "https://example.org/12"))
if tc.json != "" {
require.JSONEq(t, `{"number":12}`, out.String())
} else {
require.Equal(t, tc.out, out.String())
}
require.Equal(t, tc.stderr, diagnostics.String())
})
}