Skip to content

Commit

Permalink
Fix tests for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung committed Nov 5, 2024
1 parent 8c43271 commit 75aec63
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45m
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0'
VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0'

SWIFT_CONTAINER_IMAGE = swiftlang/swift:nightly-6.0-jammy
SWIFT_CONTAINER_IMAGE = swift:6.0.2-jammy

.PHONY: clean
clean:
Expand Down
4 changes: 4 additions & 0 deletions Sources/TMDb/Networking/TMDbAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import Foundation

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

final class TMDbAPIClient: APIClient, Sendable {

private let apiKey: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// limitations under the License.
//

#if !os(Linux)

import Foundation

Check warning on line 22 in Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
import Testing

Check warning on line 23 in Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
@testable import TMDb

Check warning on line 24 in Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Indent code in accordance with the scope level. (indent)
Expand Down Expand Up @@ -142,3 +144,5 @@ final class URLSessionHTTPClientAdapterTests {
}

}

#endif
2 changes: 1 addition & 1 deletion Tests/TMDbTests/Domain/Models/MovieTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension MovieTests {
backdropPath: URL(string: "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg"),
budget: 63_000_000,
revenue: 100_853_753,
homepageURL: URL(string: ""),
homepageURL: nil,
imdbID: "tt0137523",
status: .released,
productionCompanies: [
Expand Down
2 changes: 1 addition & 1 deletion Tests/TMDbTests/Domain/Models/ShowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct ShowTests {
#expect(tvSeriesShow.date == expectedResult)
}

@Test("JSON decoding of Movie", .tags(.decoding))
@Test("JSON decoding of Show", .tags(.decoding))
func testDecodeReturnsMovie() throws {
let result = try JSONDecoder.theMovieDatabase.decode(Show.self, fromResource: "show-movie")

Expand Down
4 changes: 4 additions & 0 deletions Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import Foundation

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

final class MockURLProtocol: URLProtocol, @unchecked Sendable {

@MainActor static var data: Data?
Expand Down
10 changes: 9 additions & 1 deletion Tests/TMDbTests/Networking/TMDbAPIClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import Foundation
import Testing
@testable import TMDb

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

@Suite(.tags(.networking))
struct TMDbAPIClientTests {

Expand Down Expand Up @@ -59,7 +63,11 @@ struct TMDbAPIClientTests {
error = err as? TMDbAPIError
}

#expect(error == .invalidURL(path))
#if canImport(FoundationNetworking)
#expect(error == .unknown)
#else
#expect(error == .invalidURL(path))
#endif
}

@Test("perform has correct URL")
Expand Down

0 comments on commit 75aec63

Please sign in to comment.