MCPcopy Create free account
hub / github.com/driangle/taskmd / TestWriteJSON

Function TestWriteJSON

apps/cli/internal/cli/format_test.go:12–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestWriteJSON(t *testing.T) {
13 var buf bytes.Buffer
14 data := map[string]string{"key": "value"}
15
16 if err := WriteJSON(&buf, data); err != nil {
17 t.Fatalf("WriteJSON failed: %v", err)
18 }
19
20 // Verify it's valid JSON
21 var parsed map[string]string
22 if err := json.Unmarshal(buf.Bytes(), &parsed); err != nil {
23 t.Fatalf("output is not valid JSON: %v", err)
24 }
25 if parsed["key"] != "value" {
26 t.Errorf("expected key=value, got key=%s", parsed["key"])
27 }
28
29 // Verify indentation
30 if !strings.Contains(buf.String(), " ") {
31 t.Error("expected indented JSON output")
32 }
33}
34
35func TestWriteYAML(t *testing.T) {
36 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 2

WriteJSONFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected