Skip to content

Commit 5c6644f

Browse files
committed
Fix failing tests
1 parent e9186ac commit 5c6644f

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

internal/pkg/cli/app_init_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestAppInitOpts_Validate(t *testing.T) {
2525
inAppName string
2626
inDockerfilePath string
2727
inProjectName string
28+
inAppPort uint16
2829

2930
mockFileSystem func(mockFS afero.Fs)
3031
wantedErr error
@@ -69,6 +70,7 @@ func TestAppInitOpts_Validate(t *testing.T) {
6970
AppType: tc.inAppType,
7071
AppName: tc.inAppName,
7172
DockerfilePath: tc.inDockerfilePath,
73+
AppPort: tc.inAppPort,
7274
GlobalOpts: &GlobalOpts{projectName: tc.inProjectName},
7375
},
7476
fs: &afero.Afero{Fs: afero.NewMemMapFs()},
@@ -94,11 +96,13 @@ func TestAppInitOpts_Ask(t *testing.T) {
9496
wantedAppType = manifest.LoadBalancedWebApplication
9597
wantedAppName = "frontend"
9698
wantedDockerfilePath = "frontend/Dockerfile"
99+
wantedAppPort = 80
97100
)
98101
testCases := map[string]struct {
99102
inAppType string
100103
inAppName string
101104
inDockerfilePath string
105+
inAppPort uint16
102106

103107
mockFileSystem func(mockFS afero.Fs)
104108
mockPrompt func(m *climocks.Mockprompter)
@@ -108,6 +112,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
108112
"prompt for app type": {
109113
inAppType: "",
110114
inAppName: wantedAppName,
115+
inAppPort: wantedAppPort,
111116
inDockerfilePath: wantedDockerfilePath,
112117

113118
mockFileSystem: func(mockFS afero.Fs) {},
@@ -120,6 +125,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
120125
"return an error if fail to get app type": {
121126
inAppType: "",
122127
inAppName: wantedAppName,
128+
inAppPort: wantedAppPort,
123129
inDockerfilePath: wantedDockerfilePath,
124130

125131
mockFileSystem: func(mockFS afero.Fs) {},
@@ -132,6 +138,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
132138
"prompt for app name": {
133139
inAppType: wantedAppType,
134140
inAppName: "",
141+
inAppPort: wantedAppPort,
135142
inDockerfilePath: wantedDockerfilePath,
136143

137144
mockFileSystem: func(mockFS afero.Fs) {},
@@ -144,6 +151,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
144151
"returns an error if fail to get application name": {
145152
inAppType: wantedAppType,
146153
inAppName: "",
154+
inAppPort: wantedAppPort,
147155
inDockerfilePath: wantedDockerfilePath,
148156

149157
mockFileSystem: func(mockFS afero.Fs) {},
@@ -156,6 +164,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
156164
"choose an existing Dockerfile": {
157165
inAppType: wantedAppType,
158166
inAppName: wantedAppName,
167+
inAppPort: wantedAppPort,
159168
inDockerfilePath: "",
160169

161170
mockFileSystem: func(mockFS afero.Fs) {
@@ -180,6 +189,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
180189
"returns an error if fail to find Dockerfiles": {
181190
inAppType: wantedAppType,
182191
inAppName: wantedAppName,
192+
inAppPort: wantedAppPort,
183193
inDockerfilePath: "",
184194

185195
mockFileSystem: func(mockFS afero.Fs) {},
@@ -225,6 +235,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
225235
initAppVars: initAppVars{
226236
AppType: tc.inAppType,
227237
AppName: tc.inAppName,
238+
AppPort: tc.inAppPort,
228239
DockerfilePath: tc.inDockerfilePath,
229240
GlobalOpts: &GlobalOpts{
230241
prompt: mockPrompt,
@@ -253,6 +264,7 @@ func TestAppInitOpts_Ask(t *testing.T) {
253264

254265
func TestAppInitOpts_Execute(t *testing.T) {
255266
testCases := map[string]struct {
267+
inAppPort uint16
256268
inAppType string
257269
inAppName string
258270
inDockerfilePath string
@@ -265,6 +277,7 @@ func TestAppInitOpts_Execute(t *testing.T) {
265277
inProjectName: "project",
266278
inAppName: "frontend",
267279
inDockerfilePath: "frontend/Dockerfile",
280+
inAppPort: 80,
268281

269282
mockDependencies: func(ctrl *gomock.Controller, opts *initAppOpts) {
270283
mockWriter := climocks.NewMockwsAppManifestWriter(ctrl)
@@ -309,6 +322,7 @@ func TestAppInitOpts_Execute(t *testing.T) {
309322
inAppType: manifest.LoadBalancedWebApplication,
310323
inProjectName: "project",
311324
inAppName: "frontend",
325+
inAppPort: 80,
312326
inDockerfilePath: "frontend/Dockerfile",
313327

314328
mockDependencies: func(ctrl *gomock.Controller, opts *initAppOpts) {
@@ -330,6 +344,7 @@ func TestAppInitOpts_Execute(t *testing.T) {
330344
inAppType: manifest.LoadBalancedWebApplication,
331345
inProjectName: "project",
332346
inAppName: "frontend",
347+
inAppPort: 80,
333348
inDockerfilePath: "frontend/Dockerfile",
334349

335350
mockDependencies: func(ctrl *gomock.Controller, opts *initAppOpts) {
@@ -445,6 +460,7 @@ func TestAppInitOpts_Execute(t *testing.T) {
445460
initAppVars: initAppVars{
446461
AppType: tc.inAppType,
447462
AppName: tc.inAppName,
463+
AppPort: tc.inAppPort,
448464
DockerfilePath: tc.inDockerfilePath,
449465
GlobalOpts: &GlobalOpts{projectName: tc.inProjectName},
450466
},

internal/pkg/cli/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type initOpts struct {
6464
projectName *string
6565
appType *string
6666
appName *string
67+
appPort *uint16
6768
dockerfilePath *string
6869

6970
prompt prompter
@@ -161,6 +162,7 @@ func newInitOpts(vars initVars) (*initOpts, error) {
161162
projectName: &initProject.ProjectName,
162163
appType: &initApp.AppType,
163164
appName: &initApp.AppName,
165+
appPort: &initApp.AppPort,
164166
dockerfilePath: &initApp.DockerfilePath,
165167

166168
prompt: prompt,
@@ -183,7 +185,7 @@ containerized applications (or micro-services) that operate together.`)
183185
}
184186

185187
log.Infof("Ok great, we'll set up a %s named %s in project %s listening on port %s.\n",
186-
color.HighlightUserInput(*o.appType), color.HighlightUserInput(*o.appName), color.HighlightUserInput(*o.projectName), color.HighlightUserInput(fmt.Sprintf("%d")))
188+
color.HighlightUserInput(*o.appType), color.HighlightUserInput(*o.appName), color.HighlightUserInput(*o.projectName), color.HighlightUserInput(fmt.Sprintf("%d", *o.appPort)))
187189

188190
if err := o.initProject.Execute(); err != nil {
189191
return fmt.Errorf("execute project init: %w", err)

internal/pkg/cli/init_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TestInitOpts_Run(t *testing.T) {
147147
defer ctrl.Finish()
148148

149149
var mockProjectName, mockAppName, mockAppType string
150-
150+
var mockAppPort uint16
151151
opts := &initOpts{
152152
ShouldDeploy: tc.inShouldDeploy,
153153
promptForShouldDeploy: tc.inPromptForShouldDeploy,
@@ -163,6 +163,7 @@ func TestInitOpts_Run(t *testing.T) {
163163
projectName: &mockProjectName,
164164
appName: &mockAppName,
165165
appType: &mockAppType,
166+
appPort: &mockAppPort,
166167
}
167168
tc.expect(opts)
168169

internal/pkg/deploy/cloudformation/stack/lb_fargate_app_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func TestLBFargateStackConfig_Template(t *testing.T) {
9494
Dockerfile: "frontend/Dockerfile",
9595
},
9696
Path: "frontend",
97+
Port: 80,
9798
}),
9899
Env: &archer.Environment{
99100
Project: "phonetool",
@@ -124,6 +125,7 @@ func TestLBFargateStackConfig_Template(t *testing.T) {
124125
Dockerfile: "frontend/Dockerfile",
125126
},
126127
Path: "frontend",
128+
Port: 80,
127129
}),
128130
Env: &archer.Environment{
129131
Project: "phonetool",
@@ -198,6 +200,7 @@ func TestLBFargateStackConfig_Parameters(t *testing.T) {
198200
Dockerfile: "frontend/Dockerfile",
199201
},
200202
Path: "frontend",
203+
Port: 80,
201204
}),
202205
Env: &archer.Environment{
203206
Project: "phonetool",
@@ -278,6 +281,7 @@ func TestLBFargateStackConfig_SerializedParameters(t *testing.T) {
278281
Dockerfile: "frontend/Dockerfile",
279282
},
280283
Path: "frontend",
284+
Port: 80,
281285
}),
282286
Env: &archer.Environment{
283287
Project: "phonetool",
@@ -305,6 +309,7 @@ func TestLBFargateStackConfig_SerializedParameters(t *testing.T) {
305309
Dockerfile: "frontend/Dockerfile",
306310
},
307311
Path: "frontend",
312+
Port: 80,
308313
}),
309314
Env: &archer.Environment{
310315
Project: "phonetool",
@@ -355,6 +360,7 @@ func TestLBFargateStackConfig_Tags(t *testing.T) {
355360
Dockerfile: "frontend/Dockerfile",
356361
},
357362
Path: "frontend",
363+
Port: 80,
358364
}),
359365
Env: &archer.Environment{
360366
Project: "phonetool",

internal/pkg/manifest/app_manifest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type AppImage struct {
3939
type AppManifestProps struct {
4040
AppName string
4141
Dockerfile string
42+
AppPort uint16
4243
}
4344

4445
// UnmarshalApp deserializes the YAML input stream into a manifest object.

0 commit comments

Comments
 (0)