From e7b758450ac7251ea810617402506299af995c77 Mon Sep 17 00:00:00 2001 From: Erik Bylund Date: Wed, 30 Sep 2026 12:57:22 +0200 Subject: [PATCH] test(unity): space out player file revisions by one second Revision timestamps are stored with second granularity, so two revisions created within the same second share an identical created_at. When the backend orders revisions by created_at the sort is a tie and the relative order of those revisions is undefined, which makes the revision ordering assertions flaky. Wait one second between the operations that create revisions so each revision gets a distinct timestamp. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../PlayMode/PlayerFilesTest.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tests/LootLockerTests/PlayMode/PlayerFilesTest.cs b/Tests/LootLockerTests/PlayMode/PlayerFilesTest.cs index af193ca09..e2da5f273 100644 --- a/Tests/LootLockerTests/PlayMode/PlayerFilesTest.cs +++ b/Tests/LootLockerTests/PlayMode/PlayerFilesTest.cs @@ -378,6 +378,10 @@ public IEnumerator PlayerFiles_UpdateFile_CreatesNewRevision() yield return new WaitUntil(() => uploadDone); Assert.IsTrue(uploadedFile.success, "Initial upload failed"); + // Revision timestamps have second granularity, so revisions created within the same + // second are indistinguishable and their relative order is undefined. + yield return new WaitForSeconds(1f); + // When — update the file LootLockerPlayerFile updatedFile = new LootLockerPlayerFile(); bool updateDone = false; @@ -425,6 +429,10 @@ public IEnumerator PlayerFiles_GetFileRevision_ReturnsSpecificRevision() yield return new WaitUntil(() => uploadDone); Assert.IsTrue(uploadedFile.success, "Initial upload failed"); + // Revision timestamps have second granularity, so revisions created within the same + // second are indistinguishable and their relative order is undefined. + yield return new WaitForSeconds(1f); + // Update to create a second revision LootLockerPlayerFile updateResponse = new LootLockerPlayerFile(); bool updateDone = false; @@ -485,6 +493,10 @@ public IEnumerator PlayerFiles_PromoteFileRevision_RestoresOldRevision() yield return new WaitUntil(() => uploadDone); Assert.IsTrue(uploadedFile.success, "Initial upload failed"); + // Revision timestamps have second granularity, so revisions created within the same + // second are indistinguishable and their relative order is undefined. + yield return new WaitForSeconds(1f); + // Update to create revision 2 LootLockerPlayerFile updateResponse = new LootLockerPlayerFile(); bool updateDone = false; @@ -607,6 +619,10 @@ public IEnumerator PlayerFiles_GetFileRevisionByKey_ReturnsSpecificRevision() yield return new WaitUntil(() => firstDone); Assert.IsTrue(firstUpload.success, "First upload for get revision by key test failed"); + // Revision timestamps have second granularity, so revisions created within the same + // second are indistinguishable and their relative order is undefined. + yield return new WaitForSeconds(1f); + LootLockerPlayerFile secondUpload = new LootLockerPlayerFile(); bool secondDone = false; LootLockerSDKManager.UploadPlayerFileByKey(pathB, "test", true, fileKey, response => @@ -664,6 +680,10 @@ public IEnumerator PlayerFiles_PromoteFileRevisionByKey_PromotesRevision() yield return new WaitUntil(() => firstDone); Assert.IsTrue(firstUpload.success, "First upload for promote by key test failed"); + // Revision timestamps have second granularity, so revisions created within the same + // second are indistinguishable and their relative order is undefined. + yield return new WaitForSeconds(1f); + LootLockerPlayerFile secondUpload = new LootLockerPlayerFile(); bool secondDone = false; LootLockerSDKManager.UploadPlayerFileByKey(pathB, "test", true, fileKey, response =>