(t *testing.T)
| 113 | } |
| 114 | |
| 115 | func TestFormatHelpers(t *testing.T) { |
| 116 | t.Parallel() |
| 117 | |
| 118 | if got := compactJSON([]byte("{\n \"x\": 1\n}")); got != `{"x":1}` { |
| 119 | t.Fatalf("compactJSON() = %q, want compact JSON", got) |
| 120 | } |
| 121 | if got := formatTime(fixedTestNow); got != "2026-04-03T12:00:00Z" { |
| 122 | t.Fatalf("formatTime() = %q, want RFC3339", got) |
| 123 | } |
| 124 | if got := formatAge(func() time.Time { return fixedTestNow }, fixedTestNow.Add(-2*time.Hour)); got != "2h" { |
| 125 | t.Fatalf("formatAge() = %q, want %q", got, "2h") |
| 126 | } |
| 127 | if got := intOrDash(0); got != "--" { |
| 128 | t.Fatalf("intOrDash(0) = %q, want --", got) |
| 129 | } |
| 130 | if got := int64OrDash(2); got != "2" { |
| 131 | t.Fatalf("int64OrDash(2) = %q, want 2", got) |
| 132 | } |
| 133 | if got := firstNonEmpty("", "alpha", "beta"); got != "alpha" { |
| 134 | t.Fatalf("firstNonEmpty() = %q, want alpha", got) |
| 135 | } |
| 136 | if got := renderHumanBlocks("", "one", "two"); got != "one\n\ntwo" { |
| 137 | t.Fatalf("renderHumanBlocks() = %q, want two blocks", got) |
| 138 | } |
| 139 | if got := renderToonObject("demo", []string{"id"}, []string{"value"}); !strings.Contains(got, "demo{id}:") { |
| 140 | t.Fatalf("renderToonObject() = %q, want TOON object", got) |
| 141 | } |
| 142 | if got := renderToonArray( |
| 143 | "demo", |
| 144 | []string{"id", "text"}, |
| 145 | [][]string{{"1", `hello, "world"`}}, |
| 146 | ); got != "demo[1]{id,text}:\n 1,\"hello, \\\"world\\\"\"" { |
| 147 | t.Fatalf("renderToonArray() = %q, want escaped TOON row", got) |
| 148 | } |
| 149 | if got := renderToonArray("demo", []string{"id"}, nil); got != "demo[0]{id}:\n (empty)" { |
| 150 | t.Fatalf("renderToonArray() empty = %q, want empty marker", got) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func TestListBundleRendersJSONHumanAndToon(t *testing.T) { |
| 155 | t.Parallel() |
nothing calls this directly
no test coverage detected