فهرست منبع

Add a test to check Reconciler control flow based on SetSecretToProviders failing

Signed-off-by: Dominic Meddick <dom.meddick@engineerbetter.com>
Co-authored-by: Amr Fawzy <amr.fawzy@container-solutions.com>
James Cleveland 4 سال پیش
والد
کامیت
5153d53116
1فایلهای تغییر یافته به همراه26 افزوده شده و 14 حذف شده
  1. 26 14
      pkg/controllers/pushsecret/pushsecret_controller_test.go

+ 26 - 14
pkg/controllers/pushsecret/pushsecret_controller_test.go

@@ -136,20 +136,32 @@ var _ = Describe("pushsecret", func() {
 			})
 		})
 
-		// When("an error returns in set secret to providers", func() {
-		// 	BeforeEach(func() {
-		// 		// TODO: get r.SetSecretToProviders to return error "SetSecretToProviders"
-		// 	})
-
-		// 	It("returns the error", func() {
-		// 		namspacedName := types.NamespacedName{Namespace: "foo", Name: "Bar"}
-		// 		_, err := reconciler.Reconcile(context.Background(), ctrl.Request{NamespacedName: namspacedName})
-
-		// 		Expect(err).To(MatchError("SetSecretToProviders"))
-		// 		// Expect(client.GetCallCount()).To(Equal(1))
-		// 		// Expect(client.StatusCallCount()).To(Equal(0))
-		// 	})
-		// })
+		When("an error returns in set secret to providers", func() {
+			BeforeEach(func() {
+				client.GetStub = func(context context.Context, name types.NamespacedName, obj kubeclient.Object) error {
+					switch v := obj.(type) {
+					case *esapi.PushSecret:
+						v.Spec.SecretStoreRefs = []esapi.PushSecretStoreRef{
+							{Name: "a", Kind: "secretstore"},
+						}
+					case *v1beta1.SecretStore:
+						v.Kind = "PotatoStore"
+					}
+					switch obj.(type) {
+					default:
+						return nil
+					}
+
+				}
+			})
+
+			It("returns the error", func() {
+				namspacedName := types.NamespacedName{Namespace: "foo", Name: "Bar"}
+				_, err := reconciler.Reconcile(context.Background(), ctrl.Request{NamespacedName: namspacedName})
+
+				Expect(err).To(MatchError("could not start provider"))
+			})
+		})
 
 		When("an object is not found", func() {
 			BeforeEach(func() {