@@ -29,14 +29,24 @@ func TestFluxReportReconciler_Reconcile(t *testing.T) {
29
29
ns , err := testEnv .CreateNamespace (ctx , "test" )
30
30
g .Expect (err ).ToNot (HaveOccurred ())
31
31
32
+ // Initialize the report.
33
+ report := & fluxcdv1.FluxReport {
34
+ ObjectMeta : metav1.ObjectMeta {
35
+ Name : fluxcdv1 .DefaultInstanceName ,
36
+ Namespace : ns .Name ,
37
+ },
38
+ }
39
+ err = reportRec .initReport (ctx , report .GetName (), report .GetNamespace ())
40
+ g .Expect (err ).ToNot (HaveOccurred ())
41
+
42
+ // Create the Flux instance.
32
43
instance := & fluxcdv1.FluxInstance {
33
44
ObjectMeta : metav1.ObjectMeta {
34
45
Name : ns .Name ,
35
46
Namespace : ns .Name ,
36
47
},
37
48
Spec : getDefaultFluxSpec (),
38
49
}
39
-
40
50
err = testEnv .Create (ctx , instance )
41
51
g .Expect (err ).ToNot (HaveOccurred ())
42
52
@@ -59,17 +69,6 @@ func TestFluxReportReconciler_Reconcile(t *testing.T) {
59
69
g .Expect (err ).ToNot (HaveOccurred ())
60
70
checkInstanceReadiness (g , instance )
61
71
62
- report := & fluxcdv1.FluxReport {
63
- ObjectMeta : metav1.ObjectMeta {
64
- Name : fluxcdv1 .DefaultInstanceName ,
65
- Namespace : ns .Name ,
66
- },
67
- }
68
-
69
- // Initialize the report.
70
- err = reportRec .initReport (ctx , report .GetName (), report .GetNamespace ())
71
- g .Expect (err ).ToNot (HaveOccurred ())
72
-
73
72
// Compute instance report.
74
73
r , err = reportRec .Reconcile (ctx , reconcile.Request {
75
74
NamespacedName : client .ObjectKeyFromObject (report ),
@@ -81,6 +80,9 @@ func TestFluxReportReconciler_Reconcile(t *testing.T) {
81
80
g .Expect (err ).ToNot (HaveOccurred ())
82
81
logObject (t , report )
83
82
83
+ // Check annotation set by the instance reconciler.
84
+ g .Expect (report .GetAnnotations ()).To (HaveKey (meta .ReconcileRequestAnnotation ))
85
+
84
86
// Check reported components.
85
87
g .Expect (report .Spec .ComponentsStatus ).To (HaveLen (len (instance .Status .Components )))
86
88
g .Expect (report .Spec .ComponentsStatus [0 ].Name ).To (Equal ("helm-controller" ))
@@ -125,10 +127,11 @@ func TestFluxReportReconciler_Reconcile(t *testing.T) {
125
127
g .Expect (err ).ToNot (HaveOccurred ())
126
128
127
129
// Read the report and verify distribution.
128
- err = testClient .Get (ctx , client .ObjectKeyFromObject (report ), report )
130
+ emptyReport := & fluxcdv1.FluxReport {}
131
+ err = testClient .Get (ctx , client .ObjectKeyFromObject (report ), emptyReport )
129
132
g .Expect (err ).ToNot (HaveOccurred ())
130
- g .Expect (report .Spec .Distribution .Status ).To (Equal ("Not Installed" ))
131
- g .Expect (report .Spec .Distribution .Entitlement ).To (Equal ("Issued by " + entitlement .DefaultVendor ))
133
+ g .Expect (emptyReport .Spec .Distribution .Status ).To (Equal ("Not Installed" ))
134
+ g .Expect (emptyReport .Spec .Distribution .Entitlement ).To (Equal ("Issued by " + entitlement .DefaultVendor ))
132
135
}
133
136
134
137
func getFluxReportReconciler () * FluxReportReconciler {
0 commit comments