@@ -366,10 +366,11 @@ func TestKustomizationReconciler_VarsubNumberBool(t *testing.T) {
366366 manifests := func (name string ) []testserver.File {
367367 return []testserver.File {
368368 {
369- Name : "service-account .yaml" ,
369+ Name : "templates .yaml" ,
370370 Body : fmt .Sprintf (`
371- apiVersion: v1
372- kind: ServiceAccount
371+ ---
372+ apiVersion: source.toolkit.fluxcd.io/v1
373+ kind: GitRepository
373374metadata:
374375 name: %[1]s
375376 namespace: %[1]s
@@ -379,6 +380,27 @@ metadata:
379380 annotations:
380381 id: ${q}${number}${q}
381382 enabled: ${q}${boolean}${q}
383+ spec:
384+ interval: ${number}m
385+ url: https://host/repo
386+ ---
387+ apiVersion: v1
388+ kind: ConfigMap
389+ metadata:
390+ name: %[1]s
391+ namespace: %[1]s
392+ data:
393+ id: ${q}${number}${q}
394+ text: |
395+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at
396+ nisl sem. Nullam nec dui ipsum. Nam vehicula volutpat ipsum, ac fringilla
397+ nisl convallis sed. Aliquam porttitor turpis finibus, finibus velit ut,
398+ imperdiet mauris. Cras nec neque nulla. Maecenas semper nulla et elit
399+ dictum sagittis. Quisque tincidunt non diam non ullamcorper. Curabitur
400+ pretium urna odio, vitae ullamcorper purus mollis sit amet. Nam ac lectus
401+ ac arcu varius feugiat id fringilla massa.
402+
403+ \?
382404` , name ),
383405 },
384406 }
@@ -423,37 +445,33 @@ metadata:
423445 "boolean" : "true" ,
424446 },
425447 },
426- Wait : true ,
448+ Wait : false ,
427449 },
428450 }
429451 g .Expect (k8sClient .Create (ctx , inputK )).Should (Succeed ())
430452
431- resultSA := & corev1.ServiceAccount {}
432-
433- ensureReconciles := func (nameSuffix string ) {
434- t .Run ("reconciles successfully" + nameSuffix , func (t * testing.T ) {
435- g .Eventually (func () bool {
436- resultK := & kustomizev1.Kustomization {}
437- _ = k8sClient .Get (ctx , client .ObjectKeyFromObject (inputK ), resultK )
438- for _ , c := range resultK .Status .Conditions {
439- if c .Reason == kustomizev1 .ReconciliationSucceededReason {
440- return true
441- }
442- }
443- return false
444- }, timeout , interval ).Should (BeTrue ())
445-
446- g .Expect (k8sClient .Get (ctx , types.NamespacedName {Name : id , Namespace : id }, resultSA )).Should (Succeed ())
447- })
448- }
449-
450- ensureReconciles (" with optional ConfigMap" )
451- t .Run ("replaces vars from optional ConfigMap" , func (t * testing.T ) {
452- g .Expect (resultSA .Labels ["id" ]).To (Equal ("123" ))
453- g .Expect (resultSA .Annotations ["id" ]).To (Equal ("123" ))
454- g .Expect (resultSA .Labels ["enabled" ]).To (Equal ("true" ))
455- g .Expect (resultSA .Annotations ["enabled" ]).To (Equal ("true" ))
456- })
453+ g .Eventually (func () bool {
454+ resultK := & kustomizev1.Kustomization {}
455+ _ = k8sClient .Get (ctx , client .ObjectKeyFromObject (inputK ), resultK )
456+ for _ , c := range resultK .Status .Conditions {
457+ if c .Reason == kustomizev1 .ReconciliationSucceededReason {
458+ return true
459+ }
460+ }
461+ return false
462+ }, timeout , interval ).Should (BeTrue ())
463+
464+ resultRepo := & sourcev1.GitRepository {}
465+ g .Expect (k8sClient .Get (ctx , types.NamespacedName {Name : id , Namespace : id }, resultRepo )).Should (Succeed ())
466+ g .Expect (resultRepo .Labels ["id" ]).To (Equal ("123" ))
467+ g .Expect (resultRepo .Annotations ["id" ]).To (Equal ("123" ))
468+ g .Expect (resultRepo .Labels ["enabled" ]).To (Equal ("true" ))
469+ g .Expect (resultRepo .Annotations ["enabled" ]).To (Equal ("true" ))
470+
471+ resultCM := & corev1.ConfigMap {}
472+ g .Expect (k8sClient .Get (ctx , types.NamespacedName {Name : id , Namespace : id }, resultCM )).Should (Succeed ())
473+ g .Expect (resultCM .Data ["id" ]).To (Equal ("123" ))
474+ g .Expect (resultCM .Data ["text" ]).To (ContainSubstring (`\?` ))
457475}
458476
459477func TestKustomizationReconciler_VarsubStrict (t * testing.T ) {
0 commit comments