@@ -141,22 +141,22 @@ func TestIncidentDetailFullIDSkipsResolve(t *testing.T) {
141141 }
142142}
143143
144- // TestIncidentGetShortIDResolves: `get <6-hex>` resolves the short id, then
145- // fetches by the resolved full id via incident_ids .
144+ // TestIncidentGetShortIDResolves: `get <6-hex>` resolves the short id via
145+ // /incident/list, then fetches by the resolved full id via /incident/list-by-ids .
146146func TestIncidentGetShortIDResolves (t * testing.T ) {
147147 saveAndResetGlobals (t )
148148 stub := newGFStub (t )
149+ var paths []string
149150 stub .dataForPath = func (path string , body map [string ]any ) any {
150- // Both the resolve and the final fetch hit /incident/list; the canned
151- // row is fine for either.
151+ paths = append (paths , path )
152152 return incidentListData (incidentItem (testFullID , testShortID , "kafka backlog" ))
153153 }
154154
155155 if _ , err := execCommand ("incident" , "get" , testShortID ); err != nil {
156156 t .Fatalf ("execCommand: %v" , err )
157157 }
158- if stub . requests != 2 {
159- t .Fatalf ("requests = %d , want 2 (resolve + fetch)" , stub . requests )
158+ if want := [] string { "/incident/list" , "/incident/list-by-ids" }; ! equalStrings ( paths , want ) {
159+ t .Fatalf ("paths = %v , want %v (resolve + fetch)" , paths , want )
160160 }
161161
162162 // Resolve sent nums; final fetch sent the resolved full id via incident_ids.
@@ -169,6 +169,30 @@ func TestIncidentGetShortIDResolves(t *testing.T) {
169169 }
170170}
171171
172+ // TestIncidentGetFullIDUsesListByIDs: a full id skips the resolve and fetches
173+ // through /incident/list-by-ids. /incident/list rejects a request without a
174+ // start_time/end_time window, so the id lookup must not go through it.
175+ func TestIncidentGetFullIDUsesListByIDs (t * testing.T ) {
176+ saveAndResetGlobals (t )
177+ stub := newGFStub (t )
178+ var paths []string
179+ stub .dataForPath = func (path string , body map [string ]any ) any {
180+ paths = append (paths , path )
181+ return incidentListData (incidentItem (testFullID , testShortID , "kafka backlog" ))
182+ }
183+
184+ if _ , err := execCommand ("incident" , "get" , testFullID ); err != nil {
185+ t .Fatalf ("execCommand: %v" , err )
186+ }
187+ if want := []string {"/incident/list-by-ids" }; ! equalStrings (paths , want ) {
188+ t .Fatalf ("paths = %v, want %v" , paths , want )
189+ }
190+ ids , _ := stub .bodies [0 ]["incident_ids" ].([]any )
191+ if len (ids ) != 1 || ids [0 ] != testFullID {
192+ t .Errorf ("incident_ids = %#v, want [%q]" , stub .bodies [0 ]["incident_ids" ], testFullID )
193+ }
194+ }
195+
172196// TestIncidentListNumsReachesWire: --nums is split and sent as the nums array.
173197func TestIncidentListNumsReachesWire (t * testing.T ) {
174198 saveAndResetGlobals (t )
0 commit comments