Skip to content

Commit

Permalink
fix(e2e): quick fix to e2e test (#774)
Browse files Browse the repository at this point in the history
* fix(e2e): fix e2e test

* chore: change isProd setting to env init Execute

* chore: add unit test
  • Loading branch information
iamhopaul123 authored Mar 25, 2020
1 parent 7ee6bc6 commit 15a4f06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/pkg/cli/env_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (o *initEnvOpts) Execute() error {
if err != nil {
return fmt.Errorf("get environment struct for %s: %w", o.EnvName, err)
}
env.Prod = o.IsProduction

// 3. Add the stack set instance to the project stackset.
if err := o.addToStackset(project, env); err != nil {
Expand Down
10 changes: 8 additions & 2 deletions internal/pkg/cli/env_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func TestInitEnvOpts_Execute(t *testing.T) {
testCases := map[string]struct {
inProjectName string
inEnvName string
inProd bool

expectProjectGetter func(m *mocks.MockProjectGetter)
expectEnvCreator func(m *mocks.MockEnvironmentCreator)
Expand Down Expand Up @@ -391,6 +392,7 @@ func TestInitEnvOpts_Execute(t *testing.T) {
"success": {
inProjectName: "phonetool",
inEnvName: "test",
inProd: true,

expectProjectGetter: func(m *mocks.MockProjectGetter) {
m.EXPECT().GetProject("phonetool").Return(&archer.Project{Name: "phonetool"}, nil)
Expand All @@ -415,6 +417,7 @@ func TestInitEnvOpts_Execute(t *testing.T) {
Project: "phonetool",
Name: "test",
AccountID: "1234",
Prod: true,
Region: "mars-1",
},
Err: nil,
Expand All @@ -425,6 +428,7 @@ func TestInitEnvOpts_Execute(t *testing.T) {
AccountID: "1234",
Region: "mars-1",
Name: "test",
Prod: false,
Project: "phonetool",
}, nil)
m.EXPECT().AddEnvToProject(gomock.Any(), gomock.Any()).Return(nil)
Expand All @@ -434,6 +438,7 @@ func TestInitEnvOpts_Execute(t *testing.T) {
Project: "phonetool",
Name: "test",
AccountID: "1234",
Prod: true,
Region: "mars-1",
}).Return(nil)
},
Expand Down Expand Up @@ -582,8 +587,9 @@ func TestInitEnvOpts_Execute(t *testing.T) {

opts := &initEnvOpts{
initEnvVars: initEnvVars{
EnvName: tc.inEnvName,
GlobalOpts: &GlobalOpts{projectName: tc.inProjectName},
EnvName: tc.inEnvName,
GlobalOpts: &GlobalOpts{projectName: tc.inProjectName},
IsProduction: tc.inProd,
},
projectGetter: mockProjectGetter,
envCreator: mockEnvCreator,
Expand Down

0 comments on commit 15a4f06

Please sign in to comment.