From f0cb908afb30b841d166d2bf7903b58f401f5609 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Sun, 12 Apr 2015 23:42:17 +0100 Subject: [PATCH] test fix --- BuildaGitServerTests/GitHubServerTests.swift | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/BuildaGitServerTests/GitHubServerTests.swift b/BuildaGitServerTests/GitHubServerTests.swift index 2dca681..c582f04 100644 --- a/BuildaGitServerTests/GitHubServerTests.swift +++ b/BuildaGitServerTests/GitHubServerTests.swift @@ -56,9 +56,13 @@ class GitHubSourceTests: XCTestCase { self.tryEndpoint(.GET, endpoint: .PullRequests, params: params) { (body, error) -> () in XCTAssertNotNil(body, "Body must be non-nil") - let prs: [PullRequest] = GitHubArray(body as! NSArray) - XCTAssertGreaterThan(prs.count, 0, "We need > 0 items to test parsing") - Log.verbose("Parsed PRs: \(prs)") + if let body = body as? NSArray { + let prs: [PullRequest] = GitHubArray(body as! NSArray) + XCTAssertGreaterThan(prs.count, 0, "We need > 0 items to test parsing") + Log.verbose("Parsed PRs: \(prs)") + } else { + XCTFail("Body nil") + } } } @@ -71,9 +75,13 @@ class GitHubSourceTests: XCTestCase { self.tryEndpoint(.GET, endpoint: .Branches, params: params) { (body, error) -> () in XCTAssertNotNil(body, "Body must be non-nil") - let branches: [Branch] = GitHubArray(body as! NSArray) - XCTAssertGreaterThan(branches.count, 0, "We need > 0 items to test parsing") - Log.verbose("Parsed branches: \(branches)") + if let body = body as? NSArray { + let branches: [Branch] = GitHubArray(body) + XCTAssertGreaterThan(branches.count, 0, "We need > 0 items to test parsing") + Log.verbose("Parsed branches: \(branches)") + } else { + XCTFail("Body nil") + } } }