@@ -87,6 +87,13 @@ func APIGateway(t *testing.T) {
8787 t .Fatalf ("failed to validate APIGateway deployment adapter: %v" , err )
8888 }
8989
90+ stageSource := adapters .NewAPIGatewayStageAdapter (testClient , accountID , testAWSConfig .Region )
91+
92+ err = stageSource .Validate ()
93+ if err != nil {
94+ t .Fatalf ("failed to validate APIGateway stage adapter: %v" , err )
95+ }
96+
9097 // Tests ----------------------------------------------------------------------------------------------------------
9198
9299 scope := adapterhelpers .FormatScope (accountID , testAWSConfig .Region )
@@ -458,5 +465,76 @@ func APIGateway(t *testing.T) {
458465 t .Fatalf ("expected deployment ID %s, got %s" , deploymentID , deploymentIDFromSearch )
459466 }
460467
468+ // Search stages by restApiID
469+ stages , err := stageSource .Search (ctx , scope , restApiID , true )
470+ if err != nil {
471+ t .Fatalf ("failed to search APIGateway stages: %v" , err )
472+ }
473+
474+ if len (stages ) == 0 {
475+ t .Fatalf ("no stages found" )
476+ }
477+
478+ stageUniqueAttribute := stages [0 ].GetUniqueAttribute ()
479+
480+ stageID , err := integration .GetUniqueAttributeValueBySignificantAttribute (
481+ stageUniqueAttribute ,
482+ "StageName" ,
483+ "dev" ,
484+ stages ,
485+ true ,
486+ )
487+ if err != nil {
488+ t .Fatalf ("failed to get stage ID: %v" , err )
489+ }
490+
491+ // Get stage
492+ query = fmt .Sprintf ("%s/dev" , restApiID )
493+ stage , err := stageSource .Get (ctx , scope , query , true )
494+ if err != nil {
495+ t .Fatalf ("failed to get APIGateway stage: %v" , err )
496+ }
497+
498+ stageIDFromGet , err := integration .GetUniqueAttributeValueBySignificantAttribute (
499+ stageUniqueAttribute ,
500+ "StageName" ,
501+ "dev" ,
502+ []* sdp.Item {stage },
503+ true ,
504+ )
505+ if err != nil {
506+ t .Fatalf ("failed to get stage ID from get: %v" , err )
507+ }
508+
509+ if stageID != stageIDFromGet {
510+ t .Fatalf ("expected stage ID %s, got %s" , stageID , stageIDFromGet )
511+ }
512+
513+ // Search stage by restApiID/deploymentID
514+ query = fmt .Sprintf ("%s/%s" , restApiID , deploymentID )
515+ stagesFromSearch , err := stageSource .Search (ctx , scope , query , true )
516+ if err != nil {
517+ t .Fatalf ("failed to search APIGateway stages: %v" , err )
518+ }
519+
520+ if len (stagesFromSearch ) == 0 {
521+ t .Fatalf ("no stages found" )
522+ }
523+
524+ stageIDFromSearch , err := integration .GetUniqueAttributeValueBySignificantAttribute (
525+ stageUniqueAttribute ,
526+ "StageName" ,
527+ "dev" ,
528+ stagesFromSearch ,
529+ true ,
530+ )
531+ if err != nil {
532+ t .Fatalf ("failed to get stage ID from search: %v" , err )
533+ }
534+
535+ if stageID != stageIDFromSearch {
536+ t .Fatalf ("expected stage ID %s, got %s" , stageID , stageIDFromSearch )
537+ }
538+
461539 t .Log ("APIGateway integration test completed" )
462540}
0 commit comments