88 "net/http/httptest"
99 "os"
1010 "path/filepath"
11+ "strconv"
1112 "strings"
1213 "testing"
1314
@@ -199,8 +200,8 @@ func Test_update_e2e_cmd(t *testing.T) {
199200 os .Setenv (constants .ExtensionVersionEnvName , "1.3.8" )
200201
201202 // Create two extensions
202- enable_extension (t , fakeEnv , oldVersionDirectory , "happyChipmunk" , true )
203- enable_extension (t , fakeEnv , oldVersionDirectory , "crazyChipmunk" , true )
203+ enable_extension (t , fakeEnv , oldVersionDirectory , "happyChipmunk" , true , 0 )
204+ enable_extension (t , fakeEnv , oldVersionDirectory , "crazyChipmunk" , true , 0 )
204205
205206 // Now, pretend that the extension was updated
206207 // Step 1: WALA calls Disable on our two extensions
@@ -222,8 +223,8 @@ func Test_update_e2e_cmd(t *testing.T) {
222223 install_handler (t , fakeEnv , tempDir )
223224
224225 // Now call enable and verify we did NOT re-execute the script
225- enable_extension (t , fakeEnv , newVersionDirectory , "happyChipmunk" , false )
226- enable_extension (t , fakeEnv , newVersionDirectory , "crazyChipmunk" , false )
226+ enable_extension (t , fakeEnv , newVersionDirectory , "happyChipmunk" , false , 0 )
227+ enable_extension (t , fakeEnv , newVersionDirectory , "crazyChipmunk" , false , 0 )
227228}
228229
229230func Test_udpate_e2e_problematic_version (t * testing.T ) {
@@ -250,9 +251,12 @@ func Test_udpate_e2e_problematic_version(t *testing.T) {
250251 os .Setenv (constants .ExtensionVersionEnvName , "1.3.17" )
251252
252253 // Create three extensions
253- enable_extension (t , fakeEnv , oldVersionDirectory , "happyChipmunk" , true )
254- enable_extension (t , fakeEnv , oldVersionDirectory , "crazyChipmunk" , true )
255- enable_extension (t , fakeEnv , oldVersionDirectory , "stubbornChipmunk" , true )
254+ enable_extension (t , fakeEnv , oldVersionDirectory , "happyChipmunk" , true , 0 )
255+ enable_extension (t , fakeEnv , oldVersionDirectory , "crazyChipmunk" , true , 0 )
256+ enable_extension (t , fakeEnv , oldVersionDirectory , "stubbornChipmunk" , true , 0 )
257+
258+ // Run one of them again to obtain multiple status files
259+ enable_extension (t , fakeEnv , oldVersionDirectory , "happyChipmunk" , true , 1 )
256260
257261 // Now, pretend that the extension was updated
258262 // Step 1: WALA calls Disable on our two extensions
@@ -285,9 +289,14 @@ func Test_udpate_e2e_problematic_version(t *testing.T) {
285289 install_handler (t , fakeEnv , tempDir )
286290
287291 // Now call enable and verify we did NOT re-execute the script
288- enable_extension (t , fakeEnv , newVersionDirectory , "happyChipmunk" , false )
289- enable_extension (t , fakeEnv , newVersionDirectory , "crazyChipmunk" , false )
290- enable_extension (t , fakeEnv , newVersionDirectory , "stubbornChipmunk" , false )
292+ enable_extension (t , fakeEnv , newVersionDirectory , "happyChipmunk" , false , 1 )
293+ enable_extension (t , fakeEnv , newVersionDirectory , "crazyChipmunk" , false , 0 )
294+ enable_extension (t , fakeEnv , newVersionDirectory , "stubbornChipmunk" , false , 0 )
295+
296+ // Run them again with a higher seqNo to ensure they're now executed
297+ enable_extension (t , fakeEnv , newVersionDirectory , "happyChipmunk" , true , 2 )
298+ enable_extension (t , fakeEnv , newVersionDirectory , "crazyChipmunk" , true , 1 )
299+ enable_extension (t , fakeEnv , newVersionDirectory , "stubbornChipmunk" , true , 1 )
291300}
292301
293302func install_handler (t * testing.T , fakeEnv types.HandlerEnvironment , tempDir string ) {
@@ -311,7 +320,7 @@ func generic_handler_call(t *testing.T, fakeEnv types.HandlerEnvironment, tempDi
311320 require .Equal (t , constants .ExitCode_Okay , exitCode )
312321}
313322
314- func enable_extension (t * testing.T , fakeEnv types.HandlerEnvironment , tempDir string , extName string , shouldExecuteScript bool ) {
323+ func enable_extension (t * testing.T , fakeEnv types.HandlerEnvironment , tempDir string , extName string , shouldExecuteScript bool , seqNo int ) {
315324 fakeInstanceView := types.RunCommandInstanceView {}
316325 wasCalled := false
317326
@@ -335,7 +344,7 @@ func enable_extension(t *testing.T, fakeEnv types.HandlerEnvironment, tempDir st
335344 },
336345 }
337346
338- settingsFilePath := filepath .Join (tempDir , extName + ".0 .settings" )
347+ settingsFilePath := filepath .Join (tempDir , extName + "." + strconv . Itoa ( seqNo ) + " .settings" )
339348 file , err := os .Create (settingsFilePath )
340349 require .Nil (t , err , "Could not create settings file" )
341350 encoder := json .NewEncoder (file )
@@ -347,8 +356,9 @@ func enable_extension(t *testing.T, fakeEnv types.HandlerEnvironment, tempDir st
347356 return nil , 0 // mock behavior
348357 }
349358
350- metadata := types .NewRCMetadata (extName , 0 , constants .DownloadFolder , tempDir )
359+ metadata := types .NewRCMetadata (extName , seqNo , constants .DownloadFolder , tempDir )
351360 metadata .MostRecentSequence = filepath .Join (tempDir , extName + constants .MrSeqFileExtension )
361+ metadata .SeqNum = seqNo
352362
353363 // Call the EnablePre function (Enable is the only function that has one)
354364 ctx := log .NewContext (log .NewNopLogger ())
0 commit comments