Skip to content

Commit

Permalink
Fix test that breaks to only run if not Windows or Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmichel committed Jan 7, 2024
1 parent 13308fb commit 4ed6c89
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions Tests/AuthTests/RequestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,14 @@ final class RequestsTests: XCTestCase {
}
}

#if !os(Windows) || !os(Linux)
// For some reason this crashes the testing bundle
// on Linux and Windows, skipping it.
func testSessionFromURL() async throws {
// For some reason this crashes the testing bundle
// on Linux and Windows, skipping it.
#if os(Linux) || os(Windows)
try XCTSkipIf(true)
#endif

let sut = makeSUT(fetch: { request in
let authorizationHeader = request.allHTTPHeaderFields?["Authorization"]
XCTAssertEqual(authorizationHeader, "bearer accesstoken")
return (json(named: "user"), HTTPURLResponse.empty())
return (json(named: "user"), HTTPURLResponse())
})

let currentDate = Date()
Expand Down Expand Up @@ -202,6 +199,7 @@ final class RequestsTests: XCTestCase {
XCTAssertEqual(session, expectedSession)
}
}
#endif

func testSessionFromURLWithMissingComponent() async {
let sut = makeSUT()
Expand Down Expand Up @@ -436,16 +434,3 @@ final class RequestsTests: XCTestCase {
)
}
}

extension HTTPURLResponse {
// Windows and Linux don't have the ability to empty initialize a URLResponse like `URLResponse()` so
// We provide a function that can give us the right value on an platform.
// See https://github.com/apple/swift-corelibs-foundation/pull/4778
fileprivate static func empty() -> URLResponse {
#if os(Windows) || os(Linux)
URLResponse(url: .init(string: "https://supabase.com")!, mimeType: nil, expectedContentLength: 0, textEncodingName: nil)
#else
URLResponse()
#endif
}
}

0 comments on commit 4ed6c89

Please sign in to comment.