@@ -127,6 +127,7 @@ func TestNewListOptionIndexer(t *testing.T) {
127127 store .EXPECT ().GetName ().Return (id ).AnyTimes ()
128128 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
129129 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
130+ txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
130131 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (nil ).Do (
131132 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
132133 err := f (txClient )
@@ -146,14 +147,18 @@ func TestNewListOptionIndexer(t *testing.T) {
146147 store .EXPECT ().RegisterBeforeDropAll (gomock .Any ()).AnyTimes ()
147148
148149 // create events table
150+ txClient .EXPECT ().Exec (fmt .Sprintf (dropEventsFmt , id )).Return (nil , nil )
149151 txClient .EXPECT ().Exec (fmt .Sprintf (createEventsTableFmt , id )).Return (nil , nil )
150152 // create field table
153+ txClient .EXPECT ().Exec (fmt .Sprintf (dropFieldsFmt , id )).Return (nil , nil )
151154 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsTableFmt , id , id , `"metadata.name" TEXT, "metadata.creationTimestamp" TEXT, "metadata.namespace" TEXT, "something" INT` )).Return (nil , nil )
152155 // create field table indexes
153156 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.name" , id , "metadata.name" )).Return (nil , nil )
154157 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.namespace" , id , "metadata.namespace" )).Return (nil , nil )
155158 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.creationTimestamp" , id , "metadata.creationTimestamp" )).Return (nil , nil )
156159 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , fields [0 ][0 ], id , fields [0 ][0 ])).Return (nil , nil )
160+ // create labels table
161+ txClient .EXPECT ().Exec (fmt .Sprintf (dropLabelsStmtFmt , id )).Return (nil , nil )
157162 txClient .EXPECT ().Exec (fmt .Sprintf (createLabelsTableFmt , id , id )).Return (nil , nil )
158163 txClient .EXPECT ().Exec (fmt .Sprintf (createLabelsTableIndexFmt , id , id )).Return (nil , nil )
159164 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (nil ).Do (
@@ -182,6 +187,7 @@ func TestNewListOptionIndexer(t *testing.T) {
182187 store .EXPECT ().GetName ().Return (id ).AnyTimes ()
183188 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
184189 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
190+ txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
185191 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (fmt .Errorf ("error" )).Do (
186192 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
187193 err := f (txClient )
@@ -207,6 +213,7 @@ func TestNewListOptionIndexer(t *testing.T) {
207213 store .EXPECT ().GetName ().Return (id ).AnyTimes ()
208214 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
209215 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
216+ txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
210217 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (nil ).Do (
211218 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
212219 err := f (txClient )
@@ -244,6 +251,7 @@ func TestNewListOptionIndexer(t *testing.T) {
244251 store .EXPECT ().GetName ().Return (id ).AnyTimes ()
245252 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
246253 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
254+ txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
247255 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (nil ).Do (
248256 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
249257 err := f (txClient )
@@ -262,7 +270,9 @@ func TestNewListOptionIndexer(t *testing.T) {
262270 store .EXPECT ().RegisterAfterDeleteAll (gomock .Any ()).Times (2 )
263271 store .EXPECT ().RegisterBeforeDropAll (gomock .Any ()).AnyTimes ()
264272
273+ txClient .EXPECT ().Exec (fmt .Sprintf (dropEventsFmt , id )).Return (nil , nil )
265274 txClient .EXPECT ().Exec (fmt .Sprintf (createEventsTableFmt , id )).Return (nil , nil )
275+ txClient .EXPECT ().Exec (fmt .Sprintf (dropFieldsFmt , id )).Return (nil , nil )
266276 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsTableFmt , id , id , `"metadata.name" TEXT, "metadata.creationTimestamp" TEXT, "metadata.namespace" TEXT, "something" TEXT` )).Return (nil , nil )
267277 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.name" , id , "metadata.name" )).Return (nil , fmt .Errorf ("error" ))
268278 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (fmt .Errorf ("error" )).Do (
@@ -291,6 +301,7 @@ func TestNewListOptionIndexer(t *testing.T) {
291301 store .EXPECT ().GetName ().Return (id ).AnyTimes ()
292302 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
293303 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
304+ txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
294305 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (nil ).Do (
295306 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
296307 err := f (txClient )
@@ -309,12 +320,15 @@ func TestNewListOptionIndexer(t *testing.T) {
309320 store .EXPECT ().RegisterAfterDeleteAll (gomock .Any ()).Times (2 )
310321 store .EXPECT ().RegisterBeforeDropAll (gomock .Any ()).AnyTimes ()
311322
323+ txClient .EXPECT ().Exec (fmt .Sprintf (dropEventsFmt , id )).Return (nil , nil )
312324 txClient .EXPECT ().Exec (fmt .Sprintf (createEventsTableFmt , id )).Return (nil , nil )
325+ txClient .EXPECT ().Exec (fmt .Sprintf (dropFieldsFmt , id )).Return (nil , nil )
313326 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsTableFmt , id , id , `"metadata.name" TEXT, "metadata.creationTimestamp" TEXT, "metadata.namespace" TEXT, "something" TEXT` )).Return (nil , nil )
314327 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.name" , id , "metadata.name" )).Return (nil , nil )
315328 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.namespace" , id , "metadata.namespace" )).Return (nil , nil )
316329 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.creationTimestamp" , id , "metadata.creationTimestamp" )).Return (nil , nil )
317330 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , fields [0 ][0 ], id , fields [0 ][0 ])).Return (nil , nil )
331+ txClient .EXPECT ().Exec (fmt .Sprintf (dropLabelsStmtFmt , id )).Return (nil , nil )
318332 txClient .EXPECT ().Exec (fmt .Sprintf (createLabelsTableFmt , id , id )).Return (nil , fmt .Errorf ("error" ))
319333 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (fmt .Errorf ("error" )).Do (
320334 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
@@ -342,6 +356,7 @@ func TestNewListOptionIndexer(t *testing.T) {
342356 store .EXPECT ().GetName ().Return (id ).AnyTimes ()
343357 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
344358 txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
359+ txClient .EXPECT ().Exec (gomock .Any ()).Return (nil , nil )
345360 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (nil ).Do (
346361 func (ctx context.Context , shouldEncrypt bool , f db.WithTransactionFunction ) {
347362 err := f (txClient )
@@ -360,12 +375,15 @@ func TestNewListOptionIndexer(t *testing.T) {
360375 store .EXPECT ().RegisterAfterDeleteAll (gomock .Any ()).Times (2 )
361376 store .EXPECT ().RegisterBeforeDropAll (gomock .Any ()).AnyTimes ()
362377
378+ txClient .EXPECT ().Exec (fmt .Sprintf (dropEventsFmt , id )).Return (nil , nil )
363379 txClient .EXPECT ().Exec (fmt .Sprintf (createEventsTableFmt , id )).Return (nil , nil )
380+ txClient .EXPECT ().Exec (fmt .Sprintf (dropFieldsFmt , id )).Return (nil , nil )
364381 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsTableFmt , id , id , `"metadata.name" TEXT, "metadata.creationTimestamp" TEXT, "metadata.namespace" TEXT, "something" TEXT` )).Return (nil , nil )
365382 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.name" , id , "metadata.name" )).Return (nil , nil )
366383 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.namespace" , id , "metadata.namespace" )).Return (nil , nil )
367384 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , "metadata.creationTimestamp" , id , "metadata.creationTimestamp" )).Return (nil , nil )
368385 txClient .EXPECT ().Exec (fmt .Sprintf (createFieldsIndexFmt , id , fields [0 ][0 ], id , fields [0 ][0 ])).Return (nil , nil )
386+ txClient .EXPECT ().Exec (fmt .Sprintf (dropLabelsStmtFmt , id )).Return (nil , nil )
369387 txClient .EXPECT ().Exec (fmt .Sprintf (createLabelsTableFmt , id , id )).Return (nil , nil )
370388 txClient .EXPECT ().Exec (fmt .Sprintf (createLabelsTableIndexFmt , id , id )).Return (nil , nil )
371389 store .EXPECT ().WithTransaction (gomock .Any (), true , gomock .Any ()).Return (fmt .Errorf ("error" )).Do (
0 commit comments