@@ -26,6 +26,8 @@ package controller
2626
2727import (
2828 "context"
29+ "k8s.io/apimachinery/pkg/util/yaml"
30+ "os"
2931
3032 . "github.com/onsi/ginkgo/v2"
3133 . "github.com/onsi/gomega"
@@ -48,7 +50,7 @@ var _ = Describe("WFS Controller", func() {
4850 Name : resourceName ,
4951 Namespace : "default" , // TODO(user):Modify as needed
5052 }
51- wfs := & pdoknlv3. WFS {}
53+ wfs := readV3Sample ()
5254
5355 BeforeEach (func () {
5456 By ("creating the custom resource for the Kind WFS" )
@@ -59,6 +61,7 @@ var _ = Describe("WFS Controller", func() {
5961 Name : resourceName ,
6062 Namespace : "default" ,
6163 },
64+ Spec : wfs .Spec ,
6265 // TODO(user): Specify other spec details if needed.
6366 }
6467 Expect (k8sClient .Create (ctx , resource )).To (Succeed ())
@@ -67,7 +70,9 @@ var _ = Describe("WFS Controller", func() {
6770
6871 AfterEach (func () {
6972 // TODO(user): Cleanup logic after each test, like removing the resource instance.
70- resource := & pdoknlv3.WFS {}
73+ resource := & pdoknlv3.WFS {
74+ Spec : wfs .Spec ,
75+ }
7176 err := k8sClient .Get (ctx , typeNamespacedName , resource )
7277 Expect (err ).NotTo (HaveOccurred ())
7378
@@ -90,3 +95,18 @@ var _ = Describe("WFS Controller", func() {
9095 })
9196 })
9297})
98+
99+ func readV3Sample () * pdoknlv3.WFS {
100+ yamlFile , err := os .ReadFile ("../../config/samples/v3_wfs.yaml" )
101+ if err != nil {
102+ panic (err )
103+ }
104+
105+ wfs := & pdoknlv3.WFS {}
106+ err = yaml .Unmarshal (yamlFile , wfs )
107+ if err != nil {
108+ panic (err )
109+ }
110+
111+ return wfs
112+ }
0 commit comments