@@ -13,15 +13,17 @@ import (
1313 "github.com/stackitcloud/stackit-sdk-go/services/runcommand"
1414)
1515
16- var projectIdFlag = globalflags .ProjectIdFlag
17-
1816type testCtxKey struct {}
1917
2018var testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
2119var testClient = & runcommand.APIClient {}
2220var testProjectId = uuid .NewString ()
2321var testServerId = uuid .NewString ()
24- var testCommandTemplateName = "RunShellScript"
22+
23+ const (
24+ testCommandTemplateName = "RunShellScript"
25+ testRegion = "eu02"
26+ )
2527
2628func fixtureArgValues (mods ... func (argValues []string )) []string {
2729 argValues := []string {
@@ -35,8 +37,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3537
3638func fixtureFlagValues (mods ... func (flagValues map [string ]string )) map [string ]string {
3739 flagValues := map [string ]string {
38- projectIdFlag : testProjectId ,
39- serverIdFlag : testServerId ,
40+ globalflags .ProjectIdFlag : testProjectId ,
41+ globalflags .RegionFlag : testRegion ,
42+ serverIdFlag : testServerId ,
4043 }
4144 for _ , mod := range mods {
4245 mod (flagValues )
@@ -48,6 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4851 model := & inputModel {
4952 GlobalFlagModel : & globalflags.GlobalFlagModel {
5053 ProjectId : testProjectId ,
54+ Region : testRegion ,
5155 Verbosity : globalflags .VerbosityDefault ,
5256 },
5357 ServerId : testServerId ,
@@ -60,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6064}
6165
6266func fixtureRequest (mods ... func (request * runcommand.ApiGetCommandTemplateRequest )) runcommand.ApiGetCommandTemplateRequest {
63- request := testClient .GetCommandTemplate (testCtx , testProjectId , testServerId , testCommandTemplateName )
67+ request := testClient .GetCommandTemplate (testCtx , testProjectId , testServerId , testCommandTemplateName , testRegion )
6468 for _ , mod := range mods {
6569 mod (& request )
6670 }
@@ -104,23 +108,23 @@ func TestParseInput(t *testing.T) {
104108 description : "project id missing" ,
105109 argValues : fixtureArgValues (),
106110 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
107- delete (flagValues , projectIdFlag )
111+ delete (flagValues , globalflags . ProjectIdFlag )
108112 }),
109113 isValid : false ,
110114 },
111115 {
112116 description : "project id invalid 1" ,
113117 argValues : fixtureArgValues (),
114118 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
115- flagValues [projectIdFlag ] = ""
119+ flagValues [globalflags . ProjectIdFlag ] = ""
116120 }),
117121 isValid : false ,
118122 },
119123 {
120124 description : "project id invalid 2" ,
121125 argValues : fixtureArgValues (),
122126 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
123- flagValues [projectIdFlag ] = "invalid-uuid"
127+ flagValues [globalflags . ProjectIdFlag ] = "invalid-uuid"
124128 }),
125129 isValid : false ,
126130 },
0 commit comments