Skip to content

Commit

Permalink
Fix Swift Package Manager Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Palaguta committed Apr 15, 2020
1 parent d0d23c8 commit f5a3c96
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
"version": "8.0.7"
}
},
{
"package": "OHHTTPStubs",
"repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs.git",
"state": {
"branch": null,
"revision": "e92b5a5746ef16add2a1424f1fc19529d9a75cde",
"version": "9.0.0"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
Expand Down
13 changes: 6 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/ReactiveCocoa/ReactiveSwift.git", from: "6.0.0"),
.package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0")
// stub and fixture functions don't work
// .package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", from: "9.0.0")
.package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0"),
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", from: "9.0.0")
],
targets: [
.target(name: "YoutubeEngine", dependencies: ["ReactiveSwift"], path: "Source"),
.testTarget(name: "YoutubeEngineTests",
dependencies: [
"YoutubeEngine",
"Nimble"
// "OHHTTPStubsSwift"
],
exclude: ["EngineTests.swift"])
"Nimble",
"OHHTTPStubsSwift"
]
),
],
swiftLanguageVersions: [.v5]
)
10 changes: 10 additions & 0 deletions Tests/YoutubeEngineTests/EngineTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Nimble
import OHHTTPStubs
#if SWIFT_PACKAGE
import OHHTTPStubsSwift
#endif
import ReactiveSwift
import XCTest
@testable import YoutubeEngine
Expand Down Expand Up @@ -251,7 +254,14 @@ final class EngineTests: XCTestCase {
}

private func jsonFile(_ fileName: String) -> HTTPStubsResponse {
#if SWIFT_PACKAGE
let relativePath = "Tests/YoutubeEngineTests/Responses/\(fileName).json"
let path = (FileManager.default.currentDirectoryPath as NSString)
.appendingPathComponent(relativePath)
#else
let path = Bundle(for: type(of: self)).path(forResource: fileName, ofType: "json")!
#endif

let response = fixture(filePath: path, headers: nil)
response.requestTime(0, responseTime: 0)
return response
Expand Down

0 comments on commit f5a3c96

Please sign in to comment.