Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Merge branch 'develop' of https://github.com/IBM/BluePic into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rolivieri committed Jul 10, 2017
2 parents 5649444 + 3de9324 commit 7c9449a
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions BluePic-Server/Tests/BluePicAppTests/RouteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class RouteTests: XCTestCase {
private let serverController = try? ServerController()

private var accessToken: String = ""

private let timeout: TimeInterval = 25.0

static var allTests : [(String, (RouteTests) -> () throws -> Void)] {
return [
("testPing", testPing),
("testGetTags", testGetTags),
("testPing", testPing),
("testGettingImages", testGettingImages),
("testGettingSingleImage", testGettingSingleImage),
("testGettingImagesByTag", testGettingImagesByTag),
Expand Down Expand Up @@ -121,7 +123,7 @@ class RouteTests: XCTestCase {
XCTAssertTrue(pingResult!.contains("Hello World"))
pingExpectation.fulfill()
}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testGetTags() {
Expand All @@ -137,7 +139,7 @@ class RouteTests: XCTestCase {
}
tagExpectation.fulfill()
}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

// MARK: Image related tests
Expand All @@ -161,7 +163,7 @@ class RouteTests: XCTestCase {
imageExpectation.fulfill()

}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testGettingSingleImage() {
Expand All @@ -176,7 +178,7 @@ class RouteTests: XCTestCase {
imageExpectation.fulfill()
}

waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testGettingImagesByTag() {
Expand All @@ -201,7 +203,7 @@ class RouteTests: XCTestCase {
imageExpectation.fulfill()

}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testPostingImage() {
Expand Down Expand Up @@ -284,7 +286,7 @@ class RouteTests: XCTestCase {
XCTFail("Failed to convert image dictionary to binary data.")
}

waitForExpectations(timeout: 20.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testGettingImagesForUser() {
Expand All @@ -303,7 +305,7 @@ class RouteTests: XCTestCase {
}
imageExpectation.fulfill()
}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

// MARK: User related tests
Expand All @@ -326,7 +328,7 @@ class RouteTests: XCTestCase {
}
userExpectation.fulfill()
}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testGettingSingleUser() {
Expand All @@ -343,7 +345,7 @@ class RouteTests: XCTestCase {
XCTAssertNotNil(user["_rev"].string)
userExpectation.fulfill()
}
waitForExpectations(timeout: 10.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testCreatingUser() {
Expand All @@ -366,7 +368,7 @@ class RouteTests: XCTestCase {
} catch {
XCTFail("Faild to convert dictionary to JSON")
}
waitForExpectations(timeout: 20.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

func testPushNotification() {
Expand Down Expand Up @@ -405,7 +407,7 @@ class RouteTests: XCTestCase {
}
req.end(close: true)

waitForExpectations(timeout: 15.0, handler: nil)
waitForExpectations(timeout: timeout, handler: nil)
}

}
Expand Down Expand Up @@ -524,6 +526,9 @@ private extension URLRequest {
XCTFail("Invalid request params")
return
}
print("method: \(method)")
print("path: \(path)")
print("headers: \(headers)")

if let query = url?.query {
path += "?" + query
Expand All @@ -532,7 +537,7 @@ private extension URLRequest {
let requestOptions: [ClientRequest.Options] = [.method(method), .hostname("localhost"), .port(8080), .path(path), .headers(headers)]

let req = HTTP.request(requestOptions) { resp in

print("in RESPONSE: \(resp)")
if let resp = resp, resp.statusCode == HTTPStatusCode.OK || resp.statusCode == HTTPStatusCode.accepted {
do {
var body = Data()
Expand Down

0 comments on commit 7c9449a

Please sign in to comment.