Last active
January 21, 2019 19:29
-
-
Save SeanROlszewski/decfeee6feadd436fff3273dcbde896b to your computer and use it in GitHub Desktop.
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
class CryptoCompareResponseTests: XCTestCase { | |
func test_deserialization() { | |
let path = Bundle(for: CryptoCompareResponseTests.self).path(forResource: "CryptoCompareResponse", ofType: "json")! | |
let examplePayload = try! Data(contentsOf: URL(fileURLWithPath: path)) | |
guard let response = try? JSONDecoder().decode(CryptoCompareResponse.self, from: examplePayload) else { | |
XCTFail("Was unable to decode the data from the payload") | |
return | |
} | |
guard response.data.count == 3 else { | |
XCTFail("Expected there to be 3 data points, but got \(response.data.count)") | |
return | |
} | |
XCTAssertEqual(response.data[0].time, 1515801600) | |
XCTAssertEqual(response.data[0].closingPrice, 1272.88, accuracy: 0.01) | |
XCTAssertEqual(response.data[1].time, 1516060800) | |
XCTAssertEqual(response.data[2].time, 1516320000) | |
} | |
} |
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
describe("Setup handling") { | |
afterEach { | |
let workingDirectory = self.rootTestDirectory | |
try? FileManager.default.removeItem(atPath: "\(workingDirectory)/muter.conf.json") | |
} | |
it("creates a configuration file named muter.conf.json with placeholder values in a specified directory") { | |
let workingDirectory = self.rootTestDirectory | |
guard let _ = try? setupMuter(using: FileManager.default, and: workingDirectory), | |
let contents = FileManager.default.contents(atPath: "\(workingDirectory)/muter.conf.json"), | |
let _ = try? JSONDecoder().decode(MuterConfiguration.self, from: contents) else { | |
fail("Expected a valid configuration file to be written") | |
return | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment