File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ type Kind struct {
6666
6767 // +optional
6868 // +nullable
69- ApiGroup * string `json:"apiGroup"`
69+ ApiGroup * string `json:"apiGroup,omitempty "`
7070
7171 // EventTypes the event types to log. If empty events are logged as defined in spec.
7272 // +kubebuilder:validation:MinItems=0
Original file line number Diff line number Diff line change 1+ package v1_test
2+
3+ import (
4+ "encoding/json"
5+
6+ . "github.com/onsi/ginkgo"
7+ . "github.com/onsi/gomega"
8+
9+ v1 "github.com/bakito/k8s-event-logger-operator/api/v1"
10+ "k8s.io/utils/pointer"
11+ )
12+
13+ var _ = Describe ("V1" , func () {
14+ Context ("ApiGroup serialisation" , func () {
15+ It ("should serialize an empty string" , func () {
16+ k := & v1.Kind {
17+ Name : "a" ,
18+ ApiGroup : pointer .StringPtr ("" ),
19+ }
20+ b , err := json .Marshal (k )
21+ Ω (err ).ShouldNot (HaveOccurred ())
22+ Ω (string (b )).Should (Equal (`{"name":"a","apiGroup":""}` ))
23+ })
24+ It ("not add apiGroups if nil" , func () {
25+ k := & v1.Kind {
26+ Name : "a" ,
27+ }
28+ b , err := json .Marshal (k )
29+ Ω (err ).ShouldNot (HaveOccurred ())
30+ Ω (string (b )).Should (Equal (`{"name":"a"}` ))
31+ })
32+ It ("should serialize an the apiGroup value" , func () {
33+ k := & v1.Kind {
34+ Name : "a" ,
35+ ApiGroup : pointer .StringPtr ("b" ),
36+ }
37+ b , err := json .Marshal (k )
38+ Ω (err ).ShouldNot (HaveOccurred ())
39+ Ω (string (b )).Should (Equal (`{"name":"a","apiGroup":"b"}` ))
40+ })
41+ })
42+ })
You can’t perform that action at this time.
0 commit comments