@@ -53,7 +53,7 @@ func TestList_Run(t *testing.T) {
5353 }
5454
5555 expectedError := & atlasv2.GenericOpenAPIError {}
56- expectedError .SetModel (atlasv2.ApiError {ErrorCode : cannotUseNotFlexWithFlexApisErrorCode })
56+ expectedError .SetModel (atlasv2.ApiError {ErrorCode : CannotUseNotFlexWithFlexApisErrorCode })
5757
5858 mockStore .
5959 EXPECT ().
@@ -94,3 +94,46 @@ func TestList_Run_FlexCluster(t *testing.T) {
9494 require .NoError (t , listOpts .Run ())
9595 test .VerifyOutputTemplate (t , listTemplate , expected )
9696}
97+
98+ func TestList_Run_ClusterNotFoundFallback (t * testing.T ) {
99+ ctrl := gomock .NewController (t )
100+ mockStore := NewMockLister (ctrl )
101+ buf := new (bytes.Buffer )
102+ expected := & atlasv2.PaginatedCloudBackupReplicaSet {
103+ Results : & []atlasv2.DiskBackupReplicaSet {
104+ {
105+ CloudProvider : pointer .Get ("AWS" ),
106+ Id : pointer .Get ("5f9b0b5e0b5e9d6b6e0b5e9d" ),
107+ SnapshotType : pointer .Get ("cloud" ),
108+ },
109+ * atlasv2 .NewDiskBackupReplicaSet (),
110+ },
111+ }
112+
113+ listOpts := & ListOpts {
114+ store : mockStore ,
115+ clusterName : "Cluster0" ,
116+ OutputOpts : cli.OutputOpts {
117+ Template : listTemplate ,
118+ OutWriter : buf ,
119+ },
120+ }
121+
122+ expectedError := & atlasv2.GenericOpenAPIError {}
123+ expectedError .SetModel (atlasv2.ApiError {ErrorCode : ClusterNotFoundErrorCode })
124+
125+ mockStore .
126+ EXPECT ().
127+ FlexClusterSnapshots (listOpts .newListFlexBackupsAPIParams ()).
128+ Return (nil , expectedError ).
129+ Times (1 )
130+
131+ mockStore .
132+ EXPECT ().
133+ Snapshots (listOpts .ProjectID , "Cluster0" , listOpts .NewAtlasListOptions ()).
134+ Return (expected , nil ).
135+ Times (1 )
136+
137+ require .NoError (t , listOpts .Run ())
138+ test .VerifyOutputTemplate (t , listTemplate , expected )
139+ }
0 commit comments