@@ -75,4 +75,51 @@ var _ = Describe("Migration store", func() {
7575 Expect (fakeClient .Get (context .Background (), types.NamespacedName {Name : ConfigMapName , Namespace : Namespace }, updatedCM )).To (Succeed ())
7676 Expect (updatedCM .Data ).To (HaveKeyWithValue ("test-migration" , completedAt ))
7777 })
78+
79+ It ("should return false when shared ConfigMap exists without migration key" , func () {
80+ cm := & corev1.ConfigMap {
81+ ObjectMeta : metav1.ObjectMeta {Name : ConfigMapName , Namespace : Namespace },
82+ Data : map [string ]string {"other-migration" : "2026-04-29T10:25:06Z" },
83+ }
84+ fakeClient , err := testutil .NewFakeClientWithObjects (cm )
85+ Expect (err ).NotTo (HaveOccurred ())
86+
87+ store := NewConfigMapStore (fakeClient )
88+ completed , err := store .IsCompleted (context .Background (), "test-migration" )
89+ Expect (err ).NotTo (HaveOccurred ())
90+ Expect (completed ).To (BeFalse ())
91+ })
92+
93+ It ("should preserve existing migration records" , func () {
94+ otherCompletedAt := "2026-04-29T10:25:06Z"
95+ cm := & corev1.ConfigMap {
96+ ObjectMeta : metav1.ObjectMeta {Name : ConfigMapName , Namespace : Namespace },
97+ Data : map [string ]string {"other-migration" : otherCompletedAt },
98+ }
99+ fakeClient , err := testutil .NewFakeClientWithObjects (cm )
100+ Expect (err ).NotTo (HaveOccurred ())
101+
102+ store := NewConfigMapStore (fakeClient )
103+ Expect (store .MarkCompleted (context .Background (), "test-migration" )).To (Succeed ())
104+
105+ updatedCM := & corev1.ConfigMap {}
106+ Expect (fakeClient .Get (context .Background (), types.NamespacedName {Name : ConfigMapName , Namespace : Namespace }, updatedCM )).To (Succeed ())
107+ Expect (updatedCM .Data ).To (HaveKeyWithValue ("other-migration" , otherCompletedAt ))
108+ Expect (updatedCM .Data ).To (HaveKey ("test-migration" ))
109+ })
110+
111+ It ("should initialize empty data in existing ConfigMap" , func () {
112+ cm := & corev1.ConfigMap {
113+ ObjectMeta : metav1.ObjectMeta {Name : ConfigMapName , Namespace : Namespace },
114+ }
115+ fakeClient , err := testutil .NewFakeClientWithObjects (cm )
116+ Expect (err ).NotTo (HaveOccurred ())
117+
118+ store := NewConfigMapStore (fakeClient )
119+ Expect (store .MarkCompleted (context .Background (), "test-migration" )).To (Succeed ())
120+
121+ updatedCM := & corev1.ConfigMap {}
122+ Expect (fakeClient .Get (context .Background (), types.NamespacedName {Name : ConfigMapName , Namespace : Namespace }, updatedCM )).To (Succeed ())
123+ Expect (updatedCM .Data ).To (HaveKey ("test-migration" ))
124+ })
78125})
0 commit comments