-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for ServiceBuilder and HTTPService
- Loading branch information
Showing
9 changed files
with
190 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// HTTPServiceTests.swift | ||
// HTTPServiceTests | ||
// | ||
// Created by Jeremy Fox on 8/7/19. | ||
// Copyright © 2019 Jeremy Fox. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import HTTPService | ||
|
||
class HTTPServiceTests: XCTestCase { | ||
|
||
func testServiceExecutesRequestAndReturnsParsedResultType() { | ||
let service = ServiceBuilder<GitHubService>.build() | ||
service?.execute(request: GitHubGetPullRequest(id: "123")) { (result) in | ||
switch result { | ||
case let .success(pr): | ||
XCTAssertTrue(pr?.name == "PR Name") | ||
case .failure(_): | ||
XCTFail() | ||
} | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// HTTPServiceTests.swift | ||
// HTTPServiceTests | ||
// | ||
// Created by Jeremy Fox on 8/7/19. | ||
// Copyright © 2019 Jeremy Fox. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import HTTPService | ||
|
||
class ServiceBuilderTests: XCTestCase { | ||
|
||
func testReturnsCachedService() { | ||
let ghService1 = ServiceBuilder<GitHubService>.build() | ||
let ghService2 = ServiceBuilder<GitHubService>.build() | ||
XCTAssertEqual(ghService1, ghService2) | ||
} | ||
|
||
func testPurgeRemovesCachedService() { | ||
let ghService1 = ServiceBuilder<GitHubService>.build() | ||
XCTAssertNotNil(ghService1) | ||
|
||
ServiceBuilder<GitHubService>.purgeCache() | ||
|
||
let ghService2 = ServiceBuilder<GitHubService>.build() | ||
XCTAssertNotEqual(ghService1, ghService2) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// GitHubGetPullRequest.swift | ||
// HTTPService | ||
// | ||
// Created by Jeremy Fox on 8/7/19. | ||
// Copyright © 2019 Jeremy Fox. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import HTTPService | ||
|
||
struct GitHubGetPullRequest: HTTPRequest { | ||
|
||
typealias ResultType = PullRequest | ||
typealias BodyType = HTTPRequestNoBody | ||
|
||
var endpoint = "/something" | ||
var method: HTTPMethod = .get | ||
var params: [String : Any]? | ||
var body: HTTPRequestNoBody? | ||
var headers: [String : String]? | ||
var includeServiceLevelHeaders: Bool = true | ||
var includeServiceLevelAuthorization: Bool = true | ||
|
||
let prId: String? | ||
|
||
init(id: String?) { | ||
prId = id | ||
} | ||
} |
Oops, something went wrong.