Skip to content

Commit 654be4c

Browse files
author
Clément Le Provost
committed
Add unit test for User-Agent header format
1 parent fbea648 commit 654be4c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Tests/ClientTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,16 @@ class ClientTests: XCTestCase {
403403
})
404404
waitForExpectationsWithTimeout(expectationTimeout, handler: nil)
405405
}
406+
407+
func testUserAgentHeader() {
408+
// Test that the initial value of the header is correct.
409+
XCTAssert(client.headers["User-Agent"]?.rangeOfString("^Algolia for Swift \\([0-9.]+\\)$", options: .RegularExpressionSearch) != nil)
410+
411+
// Test that changing the user agents results in a proper format.
412+
client.userAgents = [
413+
LibraryVersion(name: "ABC", version: "1.2.3"),
414+
LibraryVersion(name: "DEF", version: "4.5.6")
415+
]
416+
XCTAssertEqual(client.headers["User-Agent"], "ABC (1.2.3); DEF (4.5.6)")
417+
}
406418
}

0 commit comments

Comments
 (0)