From 090ef8186b4f5dd0ec44de6a5dabbe7c04a370ba Mon Sep 17 00:00:00 2001 From: Afonso Luz Date: Wed, 28 Feb 2024 14:14:35 +0100 Subject: [PATCH] Fix non-deterministic tests Select always the same robot to schedule missions on --- backend/api.test/Client/AreaTests.cs | 2 +- backend/api.test/Client/MissionTests.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/api.test/Client/AreaTests.cs b/backend/api.test/Client/AreaTests.cs index 039c8b5b0..078c67c07 100644 --- a/backend/api.test/Client/AreaTests.cs +++ b/backend/api.test/Client/AreaTests.cs @@ -146,7 +146,7 @@ public async Task MissionIsCreatedInArea() Assert.True(robotResponse.IsSuccessStatusCode); var robots = await robotResponse.Content.ReadFromJsonAsync>(_serializerOptions); Assert.True(robots != null); - var robot = robots[0]; + var robot = robots.Where(robot => robot.Name == "Shockwave").First(); string robotId = robot.Id; // Installation diff --git a/backend/api.test/Client/MissionTests.cs b/backend/api.test/Client/MissionTests.cs index e9a6815ca..dcd420375 100644 --- a/backend/api.test/Client/MissionTests.cs +++ b/backend/api.test/Client/MissionTests.cs @@ -234,7 +234,7 @@ public async Task ScheduleOneEchoMissionTest() Assert.True(response.IsSuccessStatusCode, $"Failed to get robot from path: {robotUrl}, with status code {response.StatusCode}"); var robots = await response.Content.ReadFromJsonAsync>(_serializerOptions); Assert.True(robots != null); - var robot = robots[0]; // We do not care which robot is used + var robot = robots.Where(robot => robot.Name == "Shockwave").First(); string robotId = robot.Id; // Arrange - Area @@ -281,7 +281,7 @@ public async Task Schedule3EchoMissionsTest() Assert.True(robotResponse.IsSuccessStatusCode); var robots = await robotResponse.Content.ReadFromJsonAsync>(_serializerOptions); Assert.True(robots != null); - var robot = robots[0]; + var robot = robots.Where(robot => robot.Name == "Shockwave").First(); string robotId = robot.Id; // Arrange - Area @@ -624,7 +624,7 @@ public async Task ScheduleDuplicateEchoMissionDefinitions() Assert.True(response.IsSuccessStatusCode); var robots = await response.Content.ReadFromJsonAsync>(_serializerOptions); Assert.True(robots != null); - var robot = robots[0]; + var robot = robots.Where(robot => robot.Name == "Shockwave").First(); string robotId = robot.Id; int echoMissionId = 1; // Corresponds to mock in EchoServiceMock.cs