@@ -110,11 +110,12 @@ func TestCollectionReconcile(t *testing.T) {
110110 Interval : "10s" ,
111111 },
112112 }
113-
113+ exampleCollectorConfigMapWithoutScrapeConfig := "global: {} \n google_cloud: \n export: {} \n "
114114 testCases := []struct {
115- desc string
116- input monitoringv1.MonitoringCRD
117- expected monitoringv1.MonitoringCRD
115+ desc string
116+ input monitoringv1.MonitoringCRD
117+ expected monitoringv1.MonitoringCRD
118+ expectedCollectorConfigMap * string
118119 }{
119120 {
120121 desc : "podmonitoring: no update" ,
@@ -413,6 +414,7 @@ func TestCollectionReconcile(t *testing.T) {
413414 },
414415 },
415416 },
417+ expectedCollectorConfigMap : & exampleCollectorConfigMapWithoutScrapeConfig ,
416418 },
417419 }
418420
@@ -466,6 +468,21 @@ func TestCollectionReconcile(t *testing.T) {
466468 t .Fatal (err )
467469 }
468470
471+ if tc .expectedCollectorConfigMap != nil {
472+ collectorConfigMap := & corev1.ConfigMap {
473+ ObjectMeta : metav1.ObjectMeta {
474+ Namespace : opts .OperatorNamespace ,
475+ Name : NameCollector ,
476+ },
477+ }
478+ if err := kubeClient .Get (ctx , client .ObjectKeyFromObject (collectorConfigMap ), collectorConfigMap ); err != nil {
479+ t .Fatal (err )
480+ }
481+ if diff := cmp .Diff (* tc .expectedCollectorConfigMap , collectorConfigMap .Data ["config.yaml" ]); diff != "" {
482+ t .Fatalf ("unexpected collector configmap (-want, +got): %s" , diff )
483+ }
484+ }
485+
469486 if err := kubeClient .Get (ctx , client .ObjectKeyFromObject (tc .input ), tc .input ); err != nil {
470487 t .Fatal (err )
471488 }
0 commit comments