44 "testing"
55
66 "github.com/stakater/Reloader/internal/pkg/config"
7+ "github.com/stakater/Reloader/internal/pkg/testutil"
78)
89
910func TestConfigMapReconciler_NotFound (t * testing.T ) {
@@ -16,7 +17,7 @@ func TestConfigMapReconciler_NotFound_ReloadOnDelete(t *testing.T) {
1617 cfg := config .NewDefault ()
1718 cfg .ReloadOnDelete = true
1819
19- deployment := testDeployment ("test-deployment" , "default" , map [string ]string {
20+ deployment := testutil . NewDeployment ("test-deployment" , "default" , map [string ]string {
2021 cfg .Annotations .ConfigmapReload : "deleted-cm" ,
2122 })
2223 reconciler := newConfigMapReconciler (t , cfg , deployment )
@@ -27,16 +28,16 @@ func TestConfigMapReconciler_IgnoredNamespace(t *testing.T) {
2728 cfg := config .NewDefault ()
2829 cfg .IgnoredNamespaces = []string {"kube-system" }
2930
30- cm := testConfigMap ("test-cm" , "kube-system" )
31+ cm := testutil . NewConfigMap ("test-cm" , "kube-system" )
3132 reconciler := newConfigMapReconciler (t , cfg , cm )
3233 assertReconcileSuccess (t , reconciler , reconcileRequest ("test-cm" , "kube-system" ))
3334}
3435
3536func TestConfigMapReconciler_NoMatchingWorkloads (t * testing.T ) {
3637 cfg := config .NewDefault ()
3738
38- cm := testConfigMap ("test-cm" , "default" )
39- deployment := testDeployment ("test-deployment" , "default" , nil )
39+ cm := testutil . NewConfigMap ("test-cm" , "default" )
40+ deployment := testutil . NewDeployment ("test-deployment" , "default" , nil )
4041 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
4142 assertReconcileSuccess (t , reconciler , reconcileRequest ("test-cm" , "default" ))
4243}
@@ -45,17 +46,17 @@ func TestConfigMapReconciler_MatchingDeployment_AutoAnnotation(t *testing.T) {
4546 cfg := config .NewDefault ()
4647 cfg .AutoReloadAll = true
4748
48- cm := testConfigMap ("test-cm" , "default" )
49- deployment := testDeploymentWithEnvFrom ("test-deployment" , "default" , "test-cm" , "" )
49+ cm := testutil . NewConfigMap ("test-cm" , "default" )
50+ deployment := testutil . NewDeploymentWithEnvFrom ("test-deployment" , "default" , "test-cm" , "" )
5051 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
5152 assertReconcileSuccess (t , reconciler , reconcileRequest ("test-cm" , "default" ))
5253}
5354
5455func TestConfigMapReconciler_MatchingDeployment_ExplicitAnnotation (t * testing.T ) {
5556 cfg := config .NewDefault ()
5657
57- cm := testConfigMap ("test-cm" , "default" )
58- deployment := testDeployment ("test-deployment" , "default" , map [string ]string {
58+ cm := testutil . NewConfigMap ("test-cm" , "default" )
59+ deployment := testutil . NewDeployment ("test-deployment" , "default" , map [string ]string {
5960 cfg .Annotations .ConfigmapReload : "test-cm" ,
6061 })
6162 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
@@ -65,8 +66,8 @@ func TestConfigMapReconciler_MatchingDeployment_ExplicitAnnotation(t *testing.T)
6566func TestConfigMapReconciler_WorkloadInDifferentNamespace (t * testing.T ) {
6667 cfg := config .NewDefault ()
6768
68- cm := testConfigMap ("test-cm" , "namespace-a" )
69- deployment := testDeployment ("test-deployment" , "namespace-b" , map [string ]string {
69+ cm := testutil . NewConfigMap ("test-cm" , "namespace-a" )
70+ deployment := testutil . NewDeployment ("test-deployment" , "namespace-b" , map [string ]string {
7071 cfg .Annotations .ConfigmapReload : "test-cm" ,
7172 })
7273 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
@@ -77,8 +78,8 @@ func TestConfigMapReconciler_IgnoredWorkloadType(t *testing.T) {
7778 cfg := config .NewDefault ()
7879 cfg .IgnoredWorkloads = []string {"deployment" }
7980
80- cm := testConfigMap ("test-cm" , "default" )
81- deployment := testDeployment ("test-deployment" , "default" , map [string ]string {
81+ cm := testutil . NewConfigMap ("test-cm" , "default" )
82+ deployment := testutil . NewDeployment ("test-deployment" , "default" , map [string ]string {
8283 cfg .Annotations .ConfigmapReload : "test-cm" ,
8384 })
8485 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
@@ -88,8 +89,8 @@ func TestConfigMapReconciler_IgnoredWorkloadType(t *testing.T) {
8889func TestConfigMapReconciler_DaemonSet (t * testing.T ) {
8990 cfg := config .NewDefault ()
9091
91- cm := testConfigMap ("test-cm" , "default" )
92- daemonset := testDaemonSet ("test-daemonset" , "default" , map [string ]string {
92+ cm := testutil . NewConfigMap ("test-cm" , "default" )
93+ daemonset := testutil . NewDaemonSet ("test-daemonset" , "default" , map [string ]string {
9394 cfg .Annotations .ConfigmapReload : "test-cm" ,
9495 })
9596 reconciler := newConfigMapReconciler (t , cfg , cm , daemonset )
@@ -99,8 +100,8 @@ func TestConfigMapReconciler_DaemonSet(t *testing.T) {
99100func TestConfigMapReconciler_StatefulSet (t * testing.T ) {
100101 cfg := config .NewDefault ()
101102
102- cm := testConfigMap ("test-cm" , "default" )
103- statefulset := testStatefulSet ("test-statefulset" , "default" , map [string ]string {
103+ cm := testutil . NewConfigMap ("test-cm" , "default" )
104+ statefulset := testutil . NewStatefulSet ("test-statefulset" , "default" , map [string ]string {
104105 cfg .Annotations .ConfigmapReload : "test-cm" ,
105106 })
106107 reconciler := newConfigMapReconciler (t , cfg , cm , statefulset )
@@ -110,14 +111,14 @@ func TestConfigMapReconciler_StatefulSet(t *testing.T) {
110111func TestConfigMapReconciler_MultipleWorkloads (t * testing.T ) {
111112 cfg := config .NewDefault ()
112113
113- cm := testConfigMap ("shared-cm" , "default" )
114- deployment1 := testDeployment ("deployment-1" , "default" , map [string ]string {
114+ cm := testutil . NewConfigMap ("shared-cm" , "default" )
115+ deployment1 := testutil . NewDeployment ("deployment-1" , "default" , map [string ]string {
115116 cfg .Annotations .ConfigmapReload : "shared-cm" ,
116117 })
117- deployment2 := testDeployment ("deployment-2" , "default" , map [string ]string {
118+ deployment2 := testutil . NewDeployment ("deployment-2" , "default" , map [string ]string {
118119 cfg .Annotations .ConfigmapReload : "shared-cm" ,
119120 })
120- daemonset := testDaemonSet ("daemonset-1" , "default" , map [string ]string {
121+ daemonset := testutil . NewDaemonSet ("daemonset-1" , "default" , map [string ]string {
121122 cfg .Annotations .ConfigmapReload : "shared-cm" ,
122123 })
123124
@@ -129,8 +130,8 @@ func TestConfigMapReconciler_VolumeMount(t *testing.T) {
129130 cfg := config .NewDefault ()
130131 cfg .AutoReloadAll = true
131132
132- cm := testConfigMap ("volume-cm" , "default" )
133- deployment := testDeploymentWithVolume ("test-deployment" , "default" , "volume-cm" , "" )
133+ cm := testutil . NewConfigMap ("volume-cm" , "default" )
134+ deployment := testutil . NewDeploymentWithVolume ("test-deployment" , "default" , "volume-cm" , "" )
134135 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
135136 assertReconcileSuccess (t , reconciler , reconcileRequest ("volume-cm" , "default" ))
136137}
@@ -139,19 +140,19 @@ func TestConfigMapReconciler_ProjectedVolume(t *testing.T) {
139140 cfg := config .NewDefault ()
140141 cfg .AutoReloadAll = true
141142
142- cm := testConfigMap ("projected-cm" , "default" )
143- deployment := testDeploymentWithProjectedVolume ("test-deployment" , "default" , "projected-cm" , "" )
143+ cm := testutil . NewConfigMap ("projected-cm" , "default" )
144+ deployment := testutil . NewDeploymentWithProjectedVolume ("test-deployment" , "default" , "projected-cm" , "" )
144145 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
145146 assertReconcileSuccess (t , reconciler , reconcileRequest ("projected-cm" , "default" ))
146147}
147148
148149func TestConfigMapReconciler_SearchAnnotation (t * testing.T ) {
149150 cfg := config .NewDefault ()
150151
151- cm := testConfigMapWithAnnotations ("test-cm" , "default" , map [string ]string {
152+ cm := testutil . NewConfigMapWithAnnotations ("test-cm" , "default" , map [string ]string {
152153 cfg .Annotations .Match : "true" ,
153154 })
154- deployment := testDeployment ("test-deployment" , "default" , map [string ]string {
155+ deployment := testutil . NewDeployment ("test-deployment" , "default" , map [string ]string {
155156 cfg .Annotations .Search : "true" ,
156157 })
157158 reconciler := newConfigMapReconciler (t , cfg , cm , deployment )
0 commit comments