test: add coverage for --detailed-exitcode exit code 2 on sync
Signed-off-by: vomba <hani.harzallah@elastisys.com>
This commit is contained in:
parent
2e1415472a
commit
7533a7ea16
|
|
@ -208,7 +208,9 @@ func TestSync(t *testing.T) {
|
|||
concurrency int
|
||||
timeout int
|
||||
skipDiffOnInstall bool
|
||||
detailedExitcode bool
|
||||
error string
|
||||
errorCode int
|
||||
files map[string]string
|
||||
selectors []string
|
||||
lists map[exectest.ListKey]string
|
||||
|
|
@ -269,6 +271,7 @@ func TestSync(t *testing.T) {
|
|||
skipNeeds: tc.fields.skipNeeds,
|
||||
includeNeeds: tc.fields.includeNeeds,
|
||||
includeTransitiveNeeds: tc.fields.includeTransitiveNeeds,
|
||||
detailedExitcode: tc.detailedExitcode,
|
||||
})
|
||||
|
||||
var gotErr string
|
||||
|
|
@ -280,6 +283,16 @@ func TestSync(t *testing.T) {
|
|||
t.Fatalf("unexpected error: want (-), got (+): %s", d)
|
||||
}
|
||||
|
||||
if tc.errorCode >= 0 {
|
||||
var gotCode int
|
||||
if appErr, ok := syncErr.(*Error); ok && appErr != nil {
|
||||
gotCode = appErr.Code()
|
||||
}
|
||||
if tc.errorCode != gotCode {
|
||||
t.Fatalf("unexpected error code: got %d, want %d", gotCode, tc.errorCode)
|
||||
}
|
||||
}
|
||||
|
||||
if len(wantUpgrades) > len(helm.Releases) {
|
||||
t.Fatalf("insufficient number of upgrades: got %d, want %d", len(helm.Releases), len(wantUpgrades))
|
||||
}
|
||||
|
|
@ -680,6 +693,30 @@ releases:
|
|||
lists: map[exectest.ListKey]string{
|
||||
{Filter: "^my-release$", Flags: listFlags("default", "default")}: `NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
|
||||
my-release 4 Fri Nov 1 08:40:07 2019 DEPLOYED raw-3.1.0 3.1.0 default
|
||||
`,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("detailed-exitcode returns exit code 2 on successful sync", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
files: map[string]string{
|
||||
"/path/to/helmfile.yaml": `
|
||||
releases:
|
||||
- name: my-release
|
||||
chart: incubator/raw
|
||||
namespace: default
|
||||
`,
|
||||
},
|
||||
detailedExitcode: true,
|
||||
errorCode: 2,
|
||||
concurrency: 1,
|
||||
upgraded: []exectest.Release{
|
||||
{Name: "my-release", Flags: []string{"--kube-context", "default", "--namespace", "default"}},
|
||||
},
|
||||
lists: map[exectest.ListKey]string{
|
||||
{Filter: "^my-release$", Flags: listFlags("default", "default")}: `NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
|
||||
my-release 4 Fri Nov 1 08:40:07 2019 DEPLOYED raw-3.1.0 3.1.0 default
|
||||
`,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue