@@ -29,6 +29,9 @@ import (
2929 "fmt"
3030 "os"
3131
32+ "github.com/pdok/smooth-operator/model"
33+ smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
34+
3235 . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo bdd
3336 . "github.com/onsi/gomega" //nolint:revive // ginkgo bdd
3437 pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
@@ -175,6 +178,34 @@ var _ = Describe("Testing WFS Controller", func() {
175178 }, "10s" , "1s" ).Should (BeTrue ())
176179 })
177180
181+ It ("Respects the TTL of the WFS" , func () {
182+ By ("Creating a new resource for the Kind WFS" )
183+
184+ ttlName := testWfs .GetName () + "-ttl"
185+ ttlWfs := testWfs .DeepCopy ()
186+ ttlWfs .Name = ttlName
187+ ttlWfs .Spec .Lifecycle = & model.Lifecycle {TTLInDays : smoothoperatorutils .Pointer (int32 (0 ))}
188+ objectKeyTTLWFS := client .ObjectKeyFromObject (ttlWfs )
189+
190+ err := k8sClient .Get (ctx , objectKeyTTLWFS , ttlWfs )
191+ Expect (client .IgnoreNotFound (err )).To (Not (HaveOccurred ()))
192+ if err != nil && apierrors .IsNotFound (err ) {
193+ Expect (k8sClient .Create (ctx , ttlWfs )).To (Succeed ())
194+ }
195+
196+ // Reconcile
197+ _ , err = getWFSReconciler ().Reconcile (ctx , reconcile.Request {NamespacedName : objectKeyTTLWFS })
198+ Expect (err ).To (Not (HaveOccurred ()))
199+
200+ // Check the WFS cannot be found anymore
201+ Eventually (func () bool {
202+ err = k8sClient .Get (ctx , objectKeyTTLWFS , ttlWfs )
203+ return apierrors .IsNotFound (err )
204+ }, "10s" , "1s" ).Should (BeTrue ())
205+
206+ // Not checking owned resources because the test env does not do garbage collection
207+ })
208+
178209 It ("Should cleanup the cluster" , func () {
179210 err := k8sClient .Get (ctx , objectKeyWfs , clusterWfs )
180211 Expect (client .IgnoreNotFound (err )).NotTo (HaveOccurred ())
0 commit comments