@@ -213,29 +213,37 @@ func TestIncidentListStructuredDefaultUsesCompactProjection(t *testing.T) {
213213 stub := newGFStub (t )
214214 stub .data = map [string ]any {"items" : []any {incidentRow ()}, "total" : 1 }
215215
216- out , err := execCommand ("incident" , "list" , "--output-format" , "json" )
216+ out , stderrText , err := execCommandSplit ("incident" , "list" , "--output-format" , "json" )
217217 if err != nil {
218- t .Fatalf ("execCommand : %v" , err )
218+ t .Fatalf ("execCommandSplit : %v" , err )
219219 }
220220
221221 assertProjectedJSONFields (t , out , []string {"incident_id" , "title" , "incident_severity" , "progress" , "start_time" , "channel_id" })
222+ if ! strings .Contains (stderrText , "note: rows projected to default compact fields" ) {
223+ t .Errorf ("default projection should announce itself on stderr, got:\n %s" , stderrText )
224+ }
222225 })
223226
224227 t .Run ("toon default" , func (t * testing.T ) {
225228 saveAndResetGlobals (t )
226229 stub := newGFStub (t )
227230 stub .data = map [string ]any {"items" : []any {incidentRow ()}, "total" : 1 }
228231
229- out , err := execCommand ("incident" , "list" , "--output-format" , "toon" )
232+ out , stderrText , err := execCommandSplit ("incident" , "list" , "--output-format" , "toon" )
230233 if err != nil {
231- t .Fatalf ("execCommand : %v" , err )
234+ t .Fatalf ("execCommandSplit : %v" , err )
232235 }
233236
237+ // Positive keys must come from stdout alone: the stderr note embeds the
238+ // same field names, so a merged capture would satisfy this vacuously.
234239 for _ , key := range []string {"incident_id" , "title" , "incident_severity" , "progress" , "start_time" , "channel_id" } {
235240 if ! strings .Contains (out , key ) {
236241 t .Errorf ("default toon output missing compact key %q, got:\n %s" , key , out )
237242 }
238243 }
244+ if ! strings .Contains (stderrText , "note: rows projected to default compact fields" ) {
245+ t .Errorf ("default projection should announce itself on stderr, got:\n %s" , stderrText )
246+ }
239247 for _ , key := range []string {"responders" , "labels" , "description" } {
240248 if strings .Contains (out , key ) {
241249 t .Errorf ("default toon output should not contain full-record key %q, got:\n %s" , key , out )
@@ -489,13 +497,16 @@ func TestIncidentSimilarStructuredProjection(t *testing.T) {
489497 }
490498 stub .data = map [string ]any {"items" : items , "total" : len (items )}
491499
492- out , err := execCommand ("incident" , "similar" , "inc-1" , "--limit" , "20" , "--output-format" , "json" )
500+ out , stderrText , err := execCommandSplit ("incident" , "similar" , "inc-1" , "--limit" , "20" , "--output-format" , "json" )
493501 if err != nil {
494- t .Fatalf ("execCommand : %v" , err )
502+ t .Fatalf ("execCommandSplit : %v" , err )
495503 }
496504 if len (out ) >= 16 * 1024 {
497505 t .Fatalf ("compact similar output is %d bytes, want <16 KiB" , len (out ))
498506 }
507+ if ! strings .Contains (stderrText , "note: rows projected to default compact fields" ) {
508+ t .Errorf ("default projection should announce itself on stderr, got:\n %s" , stderrText )
509+ }
499510
500511 var rows []map [string ]json.RawMessage
501512 if err := json .Unmarshal ([]byte (strings .TrimSpace (out )), & rows ); err != nil {
@@ -614,13 +625,16 @@ func TestAlertEventListStructuredProjection(t *testing.T) {
614625 }
615626 stub .data = map [string ]any {"items" : items , "total" : len (items )}
616627
617- out , err := execCommand ("alert-event" , "list" , "--limit" , "30" , "--output-format" , "json" )
628+ out , stderrText , err := execCommandSplit ("alert-event" , "list" , "--limit" , "30" , "--output-format" , "json" )
618629 if err != nil {
619- t .Fatalf ("execCommand : %v" , err )
630+ t .Fatalf ("execCommandSplit : %v" , err )
620631 }
621632 if len (out ) >= 16 * 1024 {
622633 t .Fatalf ("compact alert-event output is %d bytes, want <16 KiB" , len (out ))
623634 }
635+ if ! strings .Contains (stderrText , "note: rows projected to default compact fields" ) {
636+ t .Errorf ("default projection should announce itself on stderr, got:\n %s" , stderrText )
637+ }
624638 var rows []map [string ]json.RawMessage
625639 if err := json .Unmarshal ([]byte (strings .TrimSpace (out )), & rows ); err != nil {
626640 t .Fatalf ("parse compact alert-event json: %v\n %s" , err , out )
0 commit comments