@@ -21,7 +21,7 @@ func setInspectCmd(t *testing.T) (*di.MockDeps, *cobra.Command) {
2121func mockSnapshotResponse () sts.QuerySnapshotResult {
2222 return sts.QuerySnapshotResult {
2323 Type : "QuerySnapshotResult" ,
24- ViewSnapshotResponse : map [string ]interface {}{
24+ SnapshotResponse : map [string ]interface {}{
2525 "_type" : "ViewSnapshot" ,
2626 "components" : []interface {}{
2727 map [string ]interface {}{
@@ -121,7 +121,7 @@ func TestTopologyInspectWithTags(t *testing.T) {
121121
122122 // Verify query contains both tags ANDed
123123 call := calls [0 ]
124- request := call .PviewSnapshotRequest
124+ request := call .PsnapshotRequest
125125 expectedQuery := `type = "test type" AND label = "service.namespace:test" AND label = "service.name:myservice"`
126126 assert .Equal (t , expectedQuery , request .Query )
127127}
@@ -141,7 +141,7 @@ func TestTopologyInspectWithIdentifiers(t *testing.T) {
141141
142142 // Verify query contains identifiers in IN clause
143143 call := calls [0 ]
144- request := call .PviewSnapshotRequest
144+ request := call .PsnapshotRequest
145145 expectedQuery := `type = "test type" AND identifier IN ("urn:test:1", "urn:test:2")`
146146 assert .Equal (t , expectedQuery , request .Query )
147147}
@@ -150,7 +150,7 @@ func TestTopologyInspectNoResults(t *testing.T) {
150150 cli , cmd := setInspectCmd (t )
151151 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = sts.QuerySnapshotResult {
152152 Type : "QuerySnapshotResult" ,
153- ViewSnapshotResponse : map [string ]interface {}{
153+ SnapshotResponse : map [string ]interface {}{
154154 "_type" : "ViewSnapshot" ,
155155 "components" : []interface {}{},
156156 "metadata" : map [string ]interface {}{
@@ -178,7 +178,7 @@ func TestTopologyInspectMultipleIdentifiers(t *testing.T) {
178178 cli , cmd := setInspectCmd (t )
179179 responseData := mockSnapshotResponse ()
180180 // Modify to include multiple identifiers
181- components := responseData .ViewSnapshotResponse ["components" ].([]interface {})
181+ components := responseData .SnapshotResponse ["components" ].([]interface {})
182182 comp := components [0 ].(map [string ]interface {})
183183 comp ["identifiers" ] = []interface {}{"urn:test:1" , "urn:test:2" , "urn:test:3" }
184184 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = responseData
@@ -199,7 +199,7 @@ func TestTopologyInspectURLEncoding(t *testing.T) {
199199 cli , cmd := setInspectCmd (t )
200200 responseData := mockSnapshotResponse ()
201201 // Set identifier with special characters
202- components := responseData .ViewSnapshotResponse ["components" ].([]interface {})
202+ components := responseData .SnapshotResponse ["components" ].([]interface {})
203203 comp := components [0 ].(map [string ]interface {})
204204 comp ["identifiers" ] = []interface {}{"urn:opentelemetry:namespace/service:component/name" }
205205 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = responseData
@@ -219,11 +219,11 @@ func TestTopologyInspectWithEnvironment(t *testing.T) {
219219 cli , cmd := setInspectCmd (t )
220220 responseData := mockSnapshotResponse ()
221221 // Add environment to component
222- components := responseData .ViewSnapshotResponse ["components" ].([]interface {})
222+ components := responseData .SnapshotResponse ["components" ].([]interface {})
223223 comp := components [0 ].(map [string ]interface {})
224224 comp ["environment" ] = float64 (123 )
225225 // Add environment to metadata
226- metadata := responseData .ViewSnapshotResponse ["metadata" ].(map [string ]interface {})
226+ metadata := responseData .SnapshotResponse ["metadata" ].(map [string ]interface {})
227227 metadata ["environments" ] = []interface {}{
228228 map [string ]interface {}{
229229 "id" : float64 (123 ),
@@ -273,23 +273,26 @@ func TestTopologyInspectWithBaseURL(t *testing.T) {
273273 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = mockSnapshotResponse ()
274274 cli .CurrentContext .URL = "https://stackstate.example.com:8080"
275275
276- di .ExecuteCommandWithContextUnsafe (& cli .Deps , cmd , "--type" , "test type" )
276+ di .ExecuteCommandWithContextUnsafe (& cli .Deps , cmd , "--type" , "test type" , "-o" , "json" )
277277
278278 // Verify base URL is included in the link
279- tableCalls := * cli .MockPrinter .TableCalls
280- assert .Len (t , tableCalls , 1 )
279+ jsonCalls := * cli .MockPrinter .PrintJsonCalls
280+ assert .Len (t , jsonCalls , 1 )
281+
282+ jsonData := jsonCalls [0 ]
283+ // Components are serialized from []Component struct
284+ components := jsonData ["components" ].([]Component )
285+ assert .NotNil (t , components )
281286
282- table := tableCalls [0 ]
283- row := table .Data [0 ]
284287 expectedLink := "https://stackstate.example.com:8080/#/components/urn:test:component:1"
285- assert .Equal (t , expectedLink , row [ 3 ] )
288+ assert .Equal (t , expectedLink , components [ 0 ]. Link )
286289}
287290
288291func TestTopologyInspectFetchTimeout (t * testing.T ) {
289292 cli , cmd := setInspectCmd (t )
290293 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = sts.QuerySnapshotResult {
291294 Type : "QuerySnapshotResult" ,
292- ViewSnapshotResponse : map [string ]interface {}{
295+ SnapshotResponse : map [string ]interface {}{
293296 "_type" : "ViewSnapshotFetchTimeout" ,
294297 "usedTimeoutSeconds" : float64 (30 ),
295298 },
@@ -307,7 +310,7 @@ func TestTopologyInspectTooManyActiveQueries(t *testing.T) {
307310 cli , cmd := setInspectCmd (t )
308311 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = sts.QuerySnapshotResult {
309312 Type : "QuerySnapshotResult" ,
310- ViewSnapshotResponse : map [string ]interface {}{
313+ SnapshotResponse : map [string ]interface {}{
311314 "_type" : "ViewSnapshotTooManyActiveQueries" ,
312315 },
313316 }
@@ -324,7 +327,7 @@ func TestTopologyInspectTopologySizeOverflow(t *testing.T) {
324327 cli , cmd := setInspectCmd (t )
325328 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = sts.QuerySnapshotResult {
326329 Type : "QuerySnapshotResult" ,
327- ViewSnapshotResponse : map [string ]interface {}{
330+ SnapshotResponse : map [string ]interface {}{
328331 "_type" : "ViewSnapshotTopologySizeOverflow" ,
329332 "maxSize" : float64 (10000 ),
330333 },
@@ -342,7 +345,7 @@ func TestTopologyInspectDataUnavailable(t *testing.T) {
342345 cli , cmd := setInspectCmd (t )
343346 cli .MockClient .ApiMocks .SnapshotApi .QuerySnapshotResponse .Result = sts.QuerySnapshotResult {
344347 Type : "QuerySnapshotResult" ,
345- ViewSnapshotResponse : map [string ]interface {}{
348+ SnapshotResponse : map [string ]interface {}{
346349 "_type" : "ViewSnapshotDataUnavailable" ,
347350 "unavailableAtEpochMs" : float64 (1000000 ),
348351 "availableSinceEpochMs" : float64 (1609459200000 ),
0 commit comments