From 3a03b7100aa5756634370834761d7ed3166b4a17 Mon Sep 17 00:00:00 2001 From: Quentin Rendu Date: Tue, 28 May 2024 10:49:17 +0200 Subject: [PATCH] Search matching table when entering results in Toulouse24 test --- api-webapp/src/test/kotlin/PairingTests.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/api-webapp/src/test/kotlin/PairingTests.kt b/api-webapp/src/test/kotlin/PairingTests.kt index bd3e6a2..7c235a6 100644 --- a/api-webapp/src/test/kotlin/PairingTests.kt +++ b/api-webapp/src/test/kotlin/PairingTests.kt @@ -501,9 +501,17 @@ class PairingTests: TestBase() { firstGameID = (games.getJson(0)!!.asObject()["id"] as Long?)!!.toInt() for (i in 0 until games.size) { val gameID = firstGameID + i - val gameRes = pairingsOG[round-1].getJson(i)!!.asObject()["r"] as String? - resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":$gameID,"result":"$gameRes"}""")).asObject() - assertTrue(resp.getBoolean("success") == true, "expecting success") + // find corresponding game (matching white id) + for (j in 0 until games.size) { + val gameOG = pairingsOG[round-1].getJson(j)!!.asObject()// ["r"] as String? + if (gameOG["w"] == games.getJson(i)!!.asObject()["w"]){ + val gameRes = gameOG["r"] as String? + resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":$gameID,"result":"$gameRes"}""")).asObject() + assertTrue(resp.getBoolean("success") == true, "expecting success") + break + } + } + } logger.info("Results succesfully entered for round $round") }