Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: zhujian <[email protected]>
  • Loading branch information
zhujian7 committed Nov 20, 2024
1 parent ab3be60 commit 1c411c6
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion test/integration/api/manifestwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ var _ = ginkgo.Describe("ManifestWork API test", func() {
gomega.Expect(err).To(gomega.HaveOccurred())
})

ginkgo.It("set feedback rule", func() {
ginkgo.It("set well known status feedback rule", func() {
work := &workv1.ManifestWork{
ObjectMeta: metav1.ObjectMeta{
Name: manifestWorkName,
Expand All @@ -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 jsonpath feedback rule", 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())
})
})
})

0 comments on commit 1c411c6

Please sign in to comment.