@@ -13,21 +13,21 @@ import (
1313 "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
1414)
1515
16- var projectIdFlag = globalflags .ProjectIdFlag
17-
1816type testCtxKey struct {}
1917
2018var testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
2119var testClient = & postgresflex.APIClient {}
2220var testProjectId = uuid .NewString ()
2321var testInstanceId = uuid .NewString ()
2422var testSchedule = "0 0 * * *"
23+ var testRegion = "eu01"
2524
2625func fixtureFlagValues (mods ... func (flagValues map [string ]string )) map [string ]string {
2726 flagValues := map [string ]string {
28- projectIdFlag : testProjectId ,
29- scheduleFlag : testSchedule ,
30- instanceIdFlag : testInstanceId ,
27+ globalflags .ProjectIdFlag : testProjectId ,
28+ globalflags .RegionFlag : testRegion ,
29+ scheduleFlag : testSchedule ,
30+ instanceIdFlag : testInstanceId ,
3131 }
3232 for _ , mod := range mods {
3333 mod (flagValues )
@@ -39,6 +39,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3939 model := & inputModel {
4040 GlobalFlagModel : & globalflags.GlobalFlagModel {
4141 ProjectId : testProjectId ,
42+ Region : testRegion ,
4243 Verbosity : globalflags .VerbosityDefault ,
4344 },
4445 InstanceId : utils .Ptr (testInstanceId ),
@@ -61,7 +62,7 @@ func fixturePayload(mods ...func(payload *postgresflex.UpdateBackupSchedulePaylo
6162}
6263
6364func fixtureRequest (mods ... func (request * postgresflex.ApiUpdateBackupScheduleRequest )) postgresflex.ApiUpdateBackupScheduleRequest {
64- request := testClient .UpdateBackupSchedule (testCtx , testProjectId , testInstanceId )
65+ request := testClient .UpdateBackupSchedule (testCtx , testProjectId , testRegion , testInstanceId )
6566 request = request .UpdateBackupSchedulePayload (fixturePayload ())
6667 for _ , mod := range mods {
6768 mod (& request )
@@ -91,21 +92,21 @@ func TestParseInput(t *testing.T) {
9192 {
9293 description : "project id missing" ,
9394 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
94- delete (flagValues , projectIdFlag )
95+ delete (flagValues , globalflags . ProjectIdFlag )
9596 }),
9697 isValid : false ,
9798 },
9899 {
99100 description : "project id invalid 1" ,
100101 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
101- flagValues [projectIdFlag ] = ""
102+ flagValues [globalflags . ProjectIdFlag ] = ""
102103 }),
103104 isValid : false ,
104105 },
105106 {
106107 description : "project id invalid 2" ,
107108 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
108- flagValues [projectIdFlag ] = "invalid-uuid"
109+ flagValues [globalflags . ProjectIdFlag ] = "invalid-uuid"
109110 }),
110111 isValid : false ,
111112 },
@@ -200,10 +201,11 @@ func TestBuildRequest(t *testing.T) {
200201 model : & inputModel {
201202 GlobalFlagModel : & globalflags.GlobalFlagModel {
202203 ProjectId : testProjectId ,
204+ Region : testRegion ,
203205 },
204206 InstanceId : utils .Ptr (testInstanceId ),
205207 },
206- expectedRequest : testClient .UpdateBackupSchedule (testCtx , testProjectId , testInstanceId ).
208+ expectedRequest : testClient .UpdateBackupSchedule (testCtx , testProjectId , testRegion , testInstanceId ).
207209 UpdateBackupSchedulePayload (postgresflex.UpdateBackupSchedulePayload {}),
208210 },
209211 }
0 commit comments