Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Add fixture processing order bug? #17

Open
juliocbcotta opened this issue Jul 3, 2018 · 0 comments
Open

Add fixture processing order bug? #17

juliocbcotta opened this issue Jul 3, 2018 · 0 comments

Comments

@juliocbcotta
Copy link

Hi, is there any assurance that the enqueue order is the processing order?
I mean the code below works "some times"...

  @Test
  fun shouldFailDueRequestOrder() {
      val url = server.url("/").toString()
      val request = Request.Builder()
              .url(url + "get")
              .build()

      val client = OkHttpClient
              .Builder()
              .build()

      server.addResponse(MockResponse()
              .setResponseCode(HttpStatus.HTTP_UNAVAILABLE))
              .ifRequestMatches()
              .pathIs("/get")

      server.addFixture(200, "test.json")
              .ifRequestMatches()
              .pathIs("/get")

      assertFalse(client.newCall(request).execute().isSuccessful)

      assertTrue(client.newCall(request).execute().isSuccessful)
  }

To make it work all times we need to move the addFixture to after the first assert.

    @Test
    fun shouldFailDueRequestOrder() {
        val url = server.url("/").toString()
        val request = Request.Builder()
                .url(url + "get")
                .build()

        val client = OkHttpClient
                .Builder()
                .build()

        server.addResponse(MockResponse()
                .setResponseCode(HttpStatus.HTTP_UNAVAILABLE))
                .ifRequestMatches()
                .pathIs("/get")

        assertFalse(client.newCall(request).execute().isSuccessful)

        server.addFixture(200, "test.json")
                .ifRequestMatches()
                .pathIs("/get")

        assertTrue(client.newCall(request).execute().isSuccessful)
    }

is this the expected behaviour? It would be helpful to be able to declare the expected requests in the beginning of each test so we split the setup from the test execution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant