diff --git a/pkg/reconciler/internal/fake/actionclient.go b/pkg/reconciler/internal/fake/actionclient.go index 610cb740..cdf5f77f 100644 --- a/pkg/reconciler/internal/fake/actionclient.go +++ b/pkg/reconciler/internal/fake/actionclient.go @@ -79,12 +79,14 @@ func NewActionClient() ActionClient { Upgrades: make([]UpgradeCall, 0), Uninstalls: make([]UninstallCall, 0), Reconciles: make([]ReconcileCall, 0), + MarkFaileds: make([]MarkFailedCall, 0), HandleGet: relFunc(errors.New("get not implemented")), HandleInstall: relFunc(errors.New("install not implemented")), HandleUpgrade: relFunc(errors.New("upgrade not implemented")), HandleUninstall: uninstFunc(errors.New("uninstall not implemented")), HandleReconcile: recFunc(errors.New("reconcile not implemented")), + HandleMarkFailed: recFunc(errors.New("mark failed not implemented")), } } diff --git a/pkg/reconciler/reconciler_test.go b/pkg/reconciler/reconciler_test.go index 695063f3..cc8ae022 100644 --- a/pkg/reconciler/reconciler_test.go +++ b/pkg/reconciler/reconciler_test.go @@ -467,9 +467,9 @@ var _ = Describe("Reconciler", func() { When("release is in pending state", func() { It("should be marked as failed", func() { - r.markFailedAfter = 5 * time.Second + fakeClient := helmfake.NewActionClient() + r.markFailedAfter = 5 * time.Minute r.actionClientGetter = helmclient.ActionClientGetterFunc(func (object client.Object) (helmclient.ActionInterface, error) { - fakeClient := helmfake.NewActionClient() fakeClient.HandleGet = func() (*release.Release, error) { return &release.Release{ Name: "example-release", @@ -480,12 +480,22 @@ var _ = Describe("Reconciler", func() { }, }, nil } + fakeClient.HandleMarkFailed = func() error { + return nil + } return &fakeClient, nil }) - result, err := r.Reconcile(ctx, req) - Expect(err).To(MatchRegexp("adsfsadf")) - Expect(result).To(Equal(reconcile.Result{})) + _, err := r.Reconcile(ctx, req) + Expect(err).ToNot(BeNil()) + Expect(err.Error()).Should(ContainSubstring("Release is in a pending (locked) state and cannot currently be modified. Release will be marked failed to allow a roll-forward in")) + + r.markFailedAfter = 1 + + _, err = r.Reconcile(ctx, req) + Expect(err).ToNot(BeNil()) + Expect(err).To(MatchError("marked release example-release as failed to allow upgrade to succeed in next reconcile attempt")) + Expect(len(fakeClient.MarkFaileds)).Should(Equal(1)) }) })