Skip to content

Commit 13ea20d

Browse files
committed
chore: guard TOON list test against JSON fallback (#9)
1 parent c93f922 commit 13ea20d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

main_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,10 +1178,16 @@ func TestToonMarshalListProducesTabularOutput(t *testing.T) {
11781178
if err != nil {
11791179
t.Fatalf("expected TOON output, got error: %v", err)
11801180
}
1181-
s := string(out)
1181+
s := strings.TrimSpace(string(out))
11821182
if len(s) == 0 {
11831183
t.Fatal("expected non-empty output")
11841184
}
1185+
// The field/value substrings below also appear in JSON, so guard that we
1186+
// actually emitted TOON and didn't silently hit the indented-JSON fallback
1187+
// (which would start with `{`).
1188+
if strings.HasPrefix(s, "{") {
1189+
t.Fatalf("expected TOON output, got JSON fallback:\n%s", s)
1190+
}
11851191
if !strings.Contains(s, "id") || !strings.Contains(s, "name") {
11861192
t.Fatalf("expected field names in TOON output, got:\n%s", s)
11871193
}

0 commit comments

Comments
 (0)