Skip to content

Commit

Permalink
Made tests pass. Becaue TestCustomrequestCreator uses a dictionary we…
Browse files Browse the repository at this point in the history
… cannot rely on the order
  • Loading branch information
kimdv committed Oct 3, 2019
1 parent 3036c97 commit 8574ab9
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions Tests/ApolloTests/RequestCreatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,8 @@ Bravo file content.

let stringToCompare = try self.string(from: data)

if #available(iOS 11, macOS 13, tvOS 11, watchOS 4, *) {
let expectedString = """
--TEST.BOUNDARY
Content-Disposition: form-data; name="test_variables"
{"episode":null}
--TEST.BOUNDARY
Content-Disposition: form-data; name="test_query"
query HeroName($episode: Episode) { hero(episode: $episode) { __typename name } }
--TEST.BOUNDARY
Content-Disposition: form-data; name="test_operationName"
HeroName
// Operation parameters may be in weird order, so let's at least check that the files and single parameter got encoded properly.
let expectedEndString = """
--TEST.BOUNDARY
Content-Disposition: form-data; name="upload"; filename="a.txt"
Content-Type: text/plain
Expand All @@ -334,32 +322,15 @@ Alpha file content.
--TEST.BOUNDARY--
"""
XCTAssertEqual(stringToCompare, expectedString)
} else {
// Operation parameters may be in weird order, so let's at least check that the files and single parameter got encoded properly.
let expectedEndString = """
--TEST.BOUNDARY
Content-Disposition: form-data; name="test_operationName"

HeroName
let expectedQueryString = """
--TEST.BOUNDARY
Content-Disposition: form-data; name="test_query"
query HeroName($episode: Episode) { hero(episode: $episode) { __typename name } }
--TEST.BOUNDARY
Content-Disposition: form-data; name="test_variables"
{"episode":null}
--TEST.BOUNDARY
Content-Disposition: form-data; name="upload"; filename="a.txt"
Content-Type: text/plain
Alpha file content.
--TEST.BOUNDARY--
"""
self.checkString(stringToCompare, includes: expectedEndString)
}
self.checkString(stringToCompare, includes: expectedEndString)
self.checkString(stringToCompare, includes: expectedQueryString)
}

func testRequestBodyWithCustomRequestCreator() {
Expand Down

0 comments on commit 8574ab9

Please sign in to comment.