Skip to content

Commit 662e094

Browse files
author
Clément Le Provost
committed
Merge pull request #61 from algolia/test/dns-timeout
Add test case for DNS resolution time-out
2 parents 7c92602 + 435f52b commit 662e094

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Tests/IndexTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,4 +914,21 @@ class IndexTests: XCTestCase {
914914
})
915915
waitForExpectationsWithTimeout(expectationTimeout, handler: nil)
916916
}
917+
918+
func testDNSTimeout() {
919+
let expectation = expectationWithDescription(#function)
920+
921+
// The DNS lookup for any host in the `algolia.biz` domain will time-out.
922+
// We generate a new host name every time to avoid any cache effect.
923+
client.readHosts[0] = "swift-\(UInt32(NSDate().timeIntervalSince1970)).algolia.biz"
924+
925+
client.listIndexes({
926+
(content, error) -> Void in
927+
if error != nil {
928+
XCTFail(error!.description)
929+
}
930+
expectation.fulfill()
931+
})
932+
waitForExpectationsWithTimeout(expectationTimeout, handler: nil)
933+
}
917934
}

0 commit comments

Comments
 (0)