@@ -13,21 +13,21 @@ import (
13
13
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
14
14
)
15
15
16
- var projectIdFlag = globalflags .ProjectIdFlag
17
-
18
16
type testCtxKey struct {}
19
17
20
18
var testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
21
19
var testClient = & postgresflex.APIClient {}
22
20
var testProjectId = uuid .NewString ()
23
21
var testInstanceId = uuid .NewString ()
24
22
var testSchedule = "0 0 * * *"
23
+ var testRegion = "eu01"
25
24
26
25
func fixtureFlagValues (mods ... func (flagValues map [string ]string )) map [string ]string {
27
26
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 ,
31
31
}
32
32
for _ , mod := range mods {
33
33
mod (flagValues )
@@ -39,6 +39,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
39
39
model := & inputModel {
40
40
GlobalFlagModel : & globalflags.GlobalFlagModel {
41
41
ProjectId : testProjectId ,
42
+ Region : testRegion ,
42
43
Verbosity : globalflags .VerbosityDefault ,
43
44
},
44
45
InstanceId : utils .Ptr (testInstanceId ),
@@ -61,7 +62,7 @@ func fixturePayload(mods ...func(payload *postgresflex.UpdateBackupSchedulePaylo
61
62
}
62
63
63
64
func fixtureRequest (mods ... func (request * postgresflex.ApiUpdateBackupScheduleRequest )) postgresflex.ApiUpdateBackupScheduleRequest {
64
- request := testClient .UpdateBackupSchedule (testCtx , testProjectId , testInstanceId )
65
+ request := testClient .UpdateBackupSchedule (testCtx , testProjectId , testRegion , testInstanceId )
65
66
request = request .UpdateBackupSchedulePayload (fixturePayload ())
66
67
for _ , mod := range mods {
67
68
mod (& request )
@@ -91,21 +92,21 @@ func TestParseInput(t *testing.T) {
91
92
{
92
93
description : "project id missing" ,
93
94
flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
94
- delete (flagValues , projectIdFlag )
95
+ delete (flagValues , globalflags . ProjectIdFlag )
95
96
}),
96
97
isValid : false ,
97
98
},
98
99
{
99
100
description : "project id invalid 1" ,
100
101
flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
101
- flagValues [projectIdFlag ] = ""
102
+ flagValues [globalflags . ProjectIdFlag ] = ""
102
103
}),
103
104
isValid : false ,
104
105
},
105
106
{
106
107
description : "project id invalid 2" ,
107
108
flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
108
- flagValues [projectIdFlag ] = "invalid-uuid"
109
+ flagValues [globalflags . ProjectIdFlag ] = "invalid-uuid"
109
110
}),
110
111
isValid : false ,
111
112
},
@@ -200,10 +201,11 @@ func TestBuildRequest(t *testing.T) {
200
201
model : & inputModel {
201
202
GlobalFlagModel : & globalflags.GlobalFlagModel {
202
203
ProjectId : testProjectId ,
204
+ Region : testRegion ,
203
205
},
204
206
InstanceId : utils .Ptr (testInstanceId ),
205
207
},
206
- expectedRequest : testClient .UpdateBackupSchedule (testCtx , testProjectId , testInstanceId ).
208
+ expectedRequest : testClient .UpdateBackupSchedule (testCtx , testProjectId , testRegion , testInstanceId ).
207
209
UpdateBackupSchedulePayload (postgresflex.UpdateBackupSchedulePayload {}),
208
210
},
209
211
}
0 commit comments