Skip to content

Commit

Permalink
chore: fix failing test broken due to rebase
Browse files Browse the repository at this point in the history
Signed-off-by: James Strachan <[email protected]>
  • Loading branch information
jstrachan committed Jan 29, 2020
1 parent 62c6a2b commit 5339afc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 39 deletions.
31 changes: 21 additions & 10 deletions pkg/cmd/step/create/helmfile/create_helmfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"strings"
"testing"

"github.com/jenkins-x/jx/pkg/cmd/testhelpers"
"github.com/jenkins-x/jx/pkg/gits"
"github.com/jenkins-x/jx/pkg/helm"
v1 "k8s.io/api/core/v1"

mocks "github.com/jenkins-x/jx/pkg/cmd/clients/mocks"
Expand Down Expand Up @@ -52,7 +55,7 @@ func TestDedupeRepositories(t *testing.T) {
assert.NoError(t, err)

// assert there are 3 repos and not 4 as one of them in the jx-applications.yaml is a duplicate
assert.Equal(t, 5, len(h.Repositories))
assert.Equal(t, 3, len(h.Repositories))

if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected helmfile generated")
Expand All @@ -76,11 +79,11 @@ func TestExtraAppValues(t *testing.T) {
err = o.Run()
assert.NoError(t, err)

h, _, err := loadHelmfile(path.Join(tempDir, "apps"))
h, _, err := loadHelmfile(path.Join(tempDir, "system"))
assert.NoError(t, err)

// assert we added the local values.yaml for the velero app
assert.Equal(t, "velero/values.yaml", h.Releases[0].Values[0])
assert.Equal(t, "velero/values.yaml", h.Releases[0].Values[1])

}

Expand All @@ -95,6 +98,7 @@ func TestExtraFlagValues(t *testing.T) {
CreateOptions: *getCreateOptions(),
}
o.SetEnvironmentContext(createTestEnvironmentContext(t))
configureTestCommonOptions(t, o)
err = o.Run()
assert.NoError(t, err)

Expand All @@ -111,11 +115,11 @@ func TestCreateNamespaceChart(t *testing.T) {
assert.NoError(t, err, "should create a temporary config dir")

o := &CreateHelmfileOptions{
outputDir: tempDir,
dir: path.Join("test_data", "create-namespace-chart"),
valueFiles: []string{"foo/bar.yaml"},
CreateOptions: *getCreateOptions(),
outputDir: tempDir,
dir: path.Join("test_data", "create-namespace-chart"),
valueFiles: []string{"foo/bar.yaml"},
}
configureTestCommonOptions(t, o)
err = o.Run()
assert.NoError(t, err)

Expand Down Expand Up @@ -144,10 +148,11 @@ func TestSystem(t *testing.T) {
assert.NoError(t, err, "should create a temporary config dir")

o := &CreateHelmfileOptions{
outputDir: tempDir,
dir: path.Join("test_data", "system"),
CreateOptions: *getCreateOptions(),
outputDir: tempDir,
dir: path.Join("test_data", "system"),
}
configureTestCommonOptions(t, o)

err = o.Run()
assert.NoError(t, err)

Expand Down Expand Up @@ -224,6 +229,12 @@ func getCreateOptions() *options.CreateOptions {
}
}

func configureTestCommonOptions(t *testing.T, o *CreateHelmfileOptions) {
co := &opts.CommonOptions{}
testhelpers.ConfigureTestOptions(co, gits.NewGitCLI(), helm.NewHelmCLI("helm", helm.V3, "", true))
o.CommonOptions = co
}

func createTestEnvironmentContext(t *testing.T) *envctx.EnvironmentContext {
versionsDir := path.Join("test_data", "jenkins-x-versions")
assert.DirExists(t, versionsDir)
Expand Down
29 changes: 0 additions & 29 deletions pkg/cmd/step/create/helmfile/test_data/expected/helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ helmDefaults:
verify: false
wait: true
releases:
- chart: stable/nginx-ingress
name: nginx-ingress
namespace: nginx
needs:
- jx/namespace-nginx
values:
- test_data/jenkins-x-versions/apps/stable/nginx-ingress/values.yaml.gotmpl
- chart: stable/velero
name: velero
namespace: velero
needs:
- jx/namespace-velero
values:
- test_data/jenkins-x-versions/apps/stable/velero/values.yaml.gotmpl
version: 2.7.4
- chart: stable/external-dns
name: external-dns
namespace: jx
Expand All @@ -41,24 +26,10 @@ releases:
- chart: ../repositories
name: repositories
namespace: jx
- chart: zloeber/namespace
name: namespace-nginx
namespace: jx
values:
- generated/nginx/values.yaml
- chart: zloeber/namespace
name: namespace-velero
namespace: jx
values:
- generated/velero/values.yaml
repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami
- name: jenkins-x
url: https://storage.googleapis.com/chartmuseum.jenkins-x.io
- name: stable
url: https://kubernetes-charts.storage.googleapis.com
- name: zloeber/namespace
url: git+https://github.com/zloeber/helm-namespace@chart
- name: zloeber/namespace
url: git+https://github.com/zloeber/helm-namespace@chart

0 comments on commit 5339afc

Please sign in to comment.