Skip to content

Commit

Permalink
Deflake test that made wrong assumptions about order of JSON array re…
Browse files Browse the repository at this point in the history
…sult
  • Loading branch information
corneliusroemer committed Nov 18, 2024
1 parent 8874674 commit a8c9786
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.loculus.backend.controller.submission

import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.hasItem
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.not
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.containsInAnyOrder
import org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.hasEntry
import org.hamcrest.Matchers.hasItem
import org.hamcrest.Matchers.hasProperty
import org.hamcrest.Matchers.hasSize
import org.hamcrest.Matchers.`is`
import org.hamcrest.Matchers.not
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
Expand Down Expand Up @@ -309,6 +312,13 @@ class DeleteSequencesEndpointTest(
)
.submissionIdMappings

val expectedPairs = accessionVersions.map { entry ->
allOf(
hasEntry("accession", entry.accession),
hasEntry("version", entry.version.toInt()),
)
}

client.deleteSequenceEntries(
scope = ALL,
accessionVersionsFilter = accessionVersions,
Expand All @@ -317,8 +327,7 @@ class DeleteSequencesEndpointTest(
.andExpect(status().isOk)
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("\$.length()").value(accessionVersions.size))
.andExpect(jsonPath("\$[0].accession").value(accessionVersions.first().accession))
.andExpect(jsonPath("\$[0].version").value(accessionVersions.first().version))
.andExpect(jsonPath("\$[*]", containsInAnyOrder(*expectedPairs.toTypedArray())))
}

@Test
Expand Down

0 comments on commit a8c9786

Please sign in to comment.