From d571742f8427bfa462a733607d2531367252ab23 Mon Sep 17 00:00:00 2001 From: zhujian Date: Wed, 20 Nov 2024 16:41:27 +0800 Subject: [PATCH] Add unit tests Signed-off-by: zhujian --- test/integration/api/manifestwork_test.go | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/test/integration/api/manifestwork_test.go b/test/integration/api/manifestwork_test.go index 49c9224d0..351b7b9a0 100644 --- a/test/integration/api/manifestwork_test.go +++ b/test/integration/api/manifestwork_test.go @@ -239,5 +239,69 @@ var _ = ginkgo.Describe("ManifestWork API test", func() { Create(context.TODO(), work, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) + + ginkgo.It("set feedback rule with same jsonpath name", func() { + work := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: manifestWorkName, + }, + Spec: workv1.ManifestWorkSpec{ + ManifestConfigs: []workv1.ManifestConfigOption{ + { + ResourceIdentifier: workv1.ResourceIdentifier{ + Resource: "foo", + Name: "test", + Namespace: "testns", + }, + FeedbackRules: []workv1.FeedbackRule{ + { + Type: workv1.JSONPathsType, + JsonPaths: []workv1.JsonPath{ + {Name: "Replica", Path: ".spec.replicas"}, + {Name: "StatusReplica", Path: ".status.replicas"}, + }, + }, + }, + }, + }, + }, + } + + _, err := hubWorkClient.WorkV1().ManifestWorks(testNamespace). + Create(context.TODO(), work, metav1.CreateOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("set feedback rule with same jsonpath name", func() { + work := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: manifestWorkName, + }, + Spec: workv1.ManifestWorkSpec{ + ManifestConfigs: []workv1.ManifestConfigOption{ + { + ResourceIdentifier: workv1.ResourceIdentifier{ + Resource: "foo", + Name: "test", + Namespace: "testns", + }, + FeedbackRules: []workv1.FeedbackRule{ + { + Type: workv1.JSONPathsType, + JsonPaths: []workv1.JsonPath{ + {Name: "Replica", Path: ".spec.replicas"}, + {Name: "Replica", Path: ".status.replicas"}, + }, + }, + }, + }, + }, + }, + } + + _, err := hubWorkClient.WorkV1().ManifestWorks(testNamespace). + Create(context.TODO(), work, metav1.CreateOptions{}) + gomega.Expect(err).To(gomega.HaveOccurred()) + }) }) })