@@ -6,12 +6,13 @@ import (
66 "time"
77
88 "github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
9+
910 "github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
1011
1112 "github.com/google/go-cmp/cmp"
1213 "github.com/google/go-cmp/cmp/cmpopts"
1314 "github.com/google/uuid"
14- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
15+ postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api "
1516
1617 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1718 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
@@ -20,7 +21,7 @@ import (
2021type testCtxKey struct {}
2122
2223var testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
23- var testClient = & postgresflex.APIClient {}
24+ var testClient = & postgresflex.APIClient {DefaultAPI : & postgresflex. DefaultAPIService {} }
2425var testProjectId = uuid .NewString ()
2526var testInstanceId = uuid .NewString ()
2627var testRegion = "eu01"
@@ -55,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5556}
5657
5758func fixtureRequest (mods ... func (request * postgresflex.ApiListBackupsRequest )) postgresflex.ApiListBackupsRequest {
58- request := testClient .ListBackups (testCtx , testProjectId , testRegion , testInstanceId )
59+ request := testClient .DefaultAPI . ListBackups (testCtx , testProjectId , testRegion , testInstanceId )
5960 for _ , mod := range mods {
6061 mod (& request )
6162 }
@@ -165,7 +166,7 @@ func TestBuildRequest(t *testing.T) {
165166
166167 diff := cmp .Diff (request , tt .expectedRequest ,
167168 cmp .AllowUnexported (tt .expectedRequest ),
168- cmpopts .EquateComparable (testCtx ),
169+ cmpopts .EquateComparable (testCtx , postgresflex. DefaultAPIService {} ),
169170 )
170171 if diff != "" {
171172 t .Fatalf ("Data does not match: %s" , diff )
@@ -176,21 +177,22 @@ func TestBuildRequest(t *testing.T) {
176177
177178func Test_outputResult (t * testing.T ) {
178179 type args struct {
179- outputFormat string
180- backups []postgresflex.Backup
180+ outputFormat string
181+ instanceLabel string
182+ backups []postgresflex.Backup
181183 }
182184 tests := []struct {
183185 name string
184186 args args
185187 wantErr bool
186188 }{
187189 {"empty" , args {}, false },
188- {"standard" , args {outputFormat : "" , backups : []postgresflex.Backup {}}, false },
189- {"complete" , args {outputFormat : "" , backups : []postgresflex.Backup {
190+ {"standard" , args {outputFormat : "" , instanceLabel : "label" , backups : []postgresflex.Backup {}}, false },
191+ {"complete" , args {outputFormat : "" , instanceLabel : "label" , backups : []postgresflex.Backup {
190192 {
191193 EndTime : utils .Ptr (time .Now ().Format (time .RFC3339 )),
192194 Id : utils .Ptr ("id" ),
193- Labels : & []string {"foo" , "bar" , "baz" },
195+ Labels : []string {"foo" , "bar" , "baz" },
194196 Name : utils .Ptr ("name" ),
195197 Options : & map [string ]string {"test1" : "test1" , "test2" : "test2" },
196198 Size : utils .Ptr (int64 (42 )),
@@ -199,7 +201,7 @@ func Test_outputResult(t *testing.T) {
199201 {
200202 EndTime : utils .Ptr (time .Now ().Format (time .RFC3339 )),
201203 Id : utils .Ptr ("id" ),
202- Labels : & []string {"foo" , "bar" , "baz" },
204+ Labels : []string {"foo" , "bar" , "baz" },
203205 Name : utils .Ptr ("name" ),
204206 Options : & map [string ]string {"test1" : "test1" , "test2" : "test2" },
205207 Size : utils .Ptr (int64 (42 )),
@@ -211,7 +213,7 @@ func Test_outputResult(t *testing.T) {
211213 params := testparams .NewTestParams ()
212214 for _ , tt := range tests {
213215 t .Run (tt .name , func (t * testing.T ) {
214- if err := outputResult (params .Printer , tt .args .outputFormat , tt .args .backups ); (err != nil ) != tt .wantErr {
216+ if err := outputResult (params .Printer , tt .args .outputFormat , tt .args .instanceLabel , tt . args . backups ); (err != nil ) != tt .wantErr {
215217 t .Errorf ("outputResult() error = %v, wantErr %v" , err , tt .wantErr )
216218 }
217219 })
0 commit comments