@@ -11,18 +11,20 @@ import (
1111 "github.com/google/go-cmp/cmp"
1212 "github.com/google/go-cmp/cmp/cmpopts"
1313 "github.com/google/uuid"
14- logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api "
14+ logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v2api "
1515)
1616
17- var projectIdFlag = globalflags .ProjectIdFlag
18-
1917type testCtxKey struct {}
2018
21- var testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
22- var testClient = & logme.APIClient {DefaultAPI : & logme.DefaultAPIService {}}
23- var testProjectId = uuid .NewString ()
24- var testInstanceId = uuid .NewString ()
25- var testCredentialsId = uuid .NewString ()
19+ var (
20+ testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
21+ testClient = & logme.APIClient {DefaultAPI : & logme.DefaultAPIService {}}
22+ testProjectId = uuid .NewString ()
23+ testInstanceId = uuid .NewString ()
24+ testCredentialsId = uuid .NewString ()
25+ )
26+
27+ const testRegion = "eu01"
2628
2729func fixtureArgValues (mods ... func (argValues []string )) []string {
2830 argValues := []string {
@@ -36,8 +38,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3638
3739func fixtureFlagValues (mods ... func (flagValues map [string ]string )) map [string ]string {
3840 flagValues := map [string ]string {
39- projectIdFlag : testProjectId ,
40- instanceIdFlag : testInstanceId ,
41+ globalflags .ProjectIdFlag : testProjectId ,
42+ globalflags .RegionFlag : testRegion ,
43+ instanceIdFlag : testInstanceId ,
4144 }
4245 for _ , mod := range mods {
4346 mod (flagValues )
@@ -49,6 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4952 model := & inputModel {
5053 GlobalFlagModel : & globalflags.GlobalFlagModel {
5154 ProjectId : testProjectId ,
55+ Region : testRegion ,
5256 Verbosity : globalflags .VerbosityDefault ,
5357 },
5458 InstanceId : testInstanceId ,
@@ -61,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6165}
6266
6367func fixtureRequest (mods ... func (request * logme.ApiGetCredentialsRequest )) logme.ApiGetCredentialsRequest {
64- request := testClient .DefaultAPI .GetCredentials (testCtx , testProjectId , testInstanceId , testCredentialsId )
68+ request := testClient .DefaultAPI .GetCredentials (testCtx , testProjectId , testRegion , testInstanceId , testCredentialsId )
6569 for _ , mod := range mods {
6670 mod (& request )
6771 }
@@ -105,23 +109,23 @@ func TestParseInput(t *testing.T) {
105109 description : "project id missing" ,
106110 argValues : fixtureArgValues (),
107111 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
108- delete (flagValues , projectIdFlag )
112+ delete (flagValues , globalflags . ProjectIdFlag )
109113 }),
110114 isValid : false ,
111115 },
112116 {
113117 description : "project id invalid 1" ,
114118 argValues : fixtureArgValues (),
115119 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
116- flagValues [projectIdFlag ] = ""
120+ flagValues [globalflags . ProjectIdFlag ] = ""
117121 }),
118122 isValid : false ,
119123 },
120124 {
121125 description : "project id invalid 2" ,
122126 argValues : fixtureArgValues (),
123127 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
124- flagValues [projectIdFlag ] = "invalid-uuid"
128+ flagValues [globalflags . ProjectIdFlag ] = "invalid-uuid"
125129 }),
126130 isValid : false ,
127131 },
0 commit comments