forked from machadovilaca/monitoring-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalert_rule_classification_patch_test.go
More file actions
40 lines (34 loc) · 1.23 KB
/
alert_rule_classification_patch_test.go
File metadata and controls
40 lines (34 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package managementrouter_test
import (
"encoding/json"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift/monitoring-plugin/internal/managementrouter"
)
var _ = Describe("AlertRuleClassificationPatch", func() {
Context("when field is omitted", func() {
It("does not mark it as set", func() {
var p managementrouter.AlertRuleClassificationPatch
Expect(json.Unmarshal([]byte(`{}`), &p)).To(Succeed())
Expect(p.ComponentSet).To(BeFalse())
Expect(p.Component).To(BeNil())
})
})
Context("when field is explicitly null", func() {
It("marks it as set and clears the value", func() {
var p managementrouter.AlertRuleClassificationPatch
Expect(json.Unmarshal([]byte(`{"openshift_io_alert_rule_component":null}`), &p)).To(Succeed())
Expect(p.ComponentSet).To(BeTrue())
Expect(p.Component).To(BeNil())
})
})
Context("when field is a string", func() {
It("marks it as set and provides the value", func() {
var p managementrouter.AlertRuleClassificationPatch
Expect(json.Unmarshal([]byte(`{"openshift_io_alert_rule_component":"team-x"}`), &p)).To(Succeed())
Expect(p.ComponentSet).To(BeTrue())
Expect(p.Component).NotTo(BeNil())
Expect(*p.Component).To(Equal("team-x"))
})
})
})