diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 36ef261a3..804f0ea80 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -137,6 +137,20 @@ subjects: namespace: {{ .Release.Namespace }} ` +var manifestWithKeepAnno = ` +apiVersion: v1 +kind: Pod +metadata: + name: pod-keep, + annotations: + "helm.sh/resource-policy": keep +spec: + containers: + - name: nemo-test + image: fake-image + cmd: fake-command + ` + type chartOptions struct { *chart.Chart } @@ -253,6 +267,15 @@ func withMultipleManifestTemplate() chartOption { } } +func withKeepAnnoManifestTemplate() chartOption { + return func(opts *chartOptions) { + sampleTemplates := []*chart.File{ + {Name: "templates/keep", Data: []byte(manifestWithKeepAnno)}, + } + opts.Templates = append(opts.Templates, sampleTemplates...) + } +} + func withKube(version string) chartOption { return func(opts *chartOptions) { opts.Metadata.KubeVersion = version diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go new file mode 100644 index 000000000..7fe649464 --- /dev/null +++ b/pkg/action/uninstall_test.go @@ -0,0 +1,19 @@ +package action + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestUninstall_deleteRelease(t *testing.T) { + is := assert.New(t) + rel := releaseStub() + rel.Chart =buildChart(withKeepAnnoManifestTemplate()) + rel.Manifest = manifestWithKeepAnno + config := actionConfigFixture(t) + unisAction := NewUninstall(config) + str, errs := unisAction.deleteRelease(rel) + is.Len(errs,0) + is.Equal("pod/pod-keep\n",str) +}