Skip to content

Add missing availability guards in tests #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extension TLSVersion {
}
}

@available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)
@available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
extension TLSConfiguration {
/// Dispatch queue used by Network framework TLS to control certificate verification
static var tlsDispatchQueue = DispatchQueue(label: "TLSDispatch")
Expand Down
27 changes: 1 addition & 26 deletions Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private func makeDefaultHTTPClient(
)
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
final class AsyncAwaitEndToEndTests: XCTestCase {
var clientGroup: EventLoopGroup!
var serverGroup: EventLoopGroup!
Expand All @@ -56,7 +57,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testSimpleGet() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -77,7 +77,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testSimplePost() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -98,7 +97,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithByteBuffer() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -121,7 +119,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithSequenceOfUInt8() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -144,7 +141,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithCollectionOfUInt8() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -167,7 +163,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithRandomAccessCollectionOfUInt8() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -190,7 +185,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithAsyncSequenceOfByteBuffers() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -217,7 +211,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithAsyncSequenceOfUInt8() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -240,7 +233,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithFragmentedAsyncSequenceOfByteBuffers() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand Down Expand Up @@ -280,7 +272,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testPostWithFragmentedAsyncSequenceOfLargeByteBuffers() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand Down Expand Up @@ -321,7 +312,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testCanceling() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -344,7 +334,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testCancelingResponseBody() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
let bin = HTTPBin(.http2(compress: false)) { _ in
HTTPEchoHandler()
Expand Down Expand Up @@ -373,7 +362,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testDeadline() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -398,7 +386,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testImmediateDeadline() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -423,7 +410,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testConnectTimeout() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 60) {
#if os(Linux)
// 198.51.100.254 is reserved for documentation only and therefore should not accept any TCP connection
Expand Down Expand Up @@ -480,7 +466,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testSelfSignedCertificateIsRejectedWithCorrectErrorIfRequestDeadlineIsExceeded() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
/// key + cert was created with the follwing command:
/// openssl req -x509 -newkey rsa:4096 -keyout self_signed_key.pem -out self_signed_cert.pem -sha256 -days 99999 -nodes -subj '/CN=localhost'
Expand Down Expand Up @@ -526,7 +511,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testDnsOverride() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
/// key + cert was created with the following code (depends on swift-certificates)
/// ```
Expand Down Expand Up @@ -584,7 +568,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testInvalidURL() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest(timeout: 5) {
let client = makeDefaultHTTPClient()
defer { XCTAssertNoThrow(try client.syncShutdown()) }
Expand All @@ -598,7 +581,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testRedirectChangesHostHeader() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -625,7 +607,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testShutdown() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let client = makeDefaultHTTPClient()
try await client.shutdown()
Expand All @@ -637,7 +618,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {

/// Regression test for https://github.com/swift-server/async-http-client/issues/612
func testCancelingBodyDoesNotCrash() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let client = makeDefaultHTTPClient()
defer { XCTAssertNoThrow(try client.syncShutdown()) }
Expand All @@ -654,7 +634,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testAsyncSequenceReuse() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() }
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand Down Expand Up @@ -698,7 +677,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

private func _rejectsInvalidCharactersInHeaderFieldNames(mode: HTTPBin<HTTPBinHandler>.Mode) {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(mode)
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand Down Expand Up @@ -759,7 +737,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

private func _rejectsInvalidCharactersInHeaderFieldValues(mode: HTTPBin<HTTPBinHandler>.Mode) {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(mode)
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand Down Expand Up @@ -818,7 +795,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testUsingGetMethodInsteadOfWait() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand All @@ -838,7 +814,6 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
}

func testSimpleContentLengthErrorNoBody() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let bin = HTTPBin(.http2(compress: false))
defer { XCTAssertNoThrow(try bin.shutdown()) }
Expand Down
17 changes: 2 additions & 15 deletions Tests/AsyncHTTPClientTests/HTTPClientRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ import Algorithms
import NIOCore
import XCTest

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
class HTTPClientRequestTests: XCTestCase {
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
private typealias Request = HTTPClientRequest

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
private typealias PreparedRequest = HTTPClientRequest.Prepared

func testCustomHeadersAreRespected() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "https://example.com/get")
request.headers = [
Expand Down Expand Up @@ -60,7 +58,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testUnixScheme() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "unix://%2Fexample%2Ffolder.sock/some_path")
request.headers = ["custom-header": "custom-value"]
Expand Down Expand Up @@ -90,7 +87,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testHTTPUnixScheme() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http+unix://%2Fexample%2Ffolder.sock/some_path")
request.headers = ["custom-header": "custom-value"]
Expand Down Expand Up @@ -120,7 +116,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testHTTPSUnixScheme() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "https+unix://%2Fexample%2Ffolder.sock/some_path")
request.headers = ["custom-header": "custom-value"]
Expand Down Expand Up @@ -150,7 +145,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testGetWithoutBody() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
let request = Request(url: "https://example.com/get")
var preparedRequest: PreparedRequest?
Expand Down Expand Up @@ -179,7 +173,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithoutBody() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -213,7 +206,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithEmptyByteBuffer() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -248,7 +240,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithByteBuffer() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -282,7 +273,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithSequenceOfUnknownLength() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -317,7 +307,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithSequenceWithFixedLength() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -353,7 +342,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithRandomAccessCollection() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -388,7 +376,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithAsyncSequenceOfUnknownLength() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -428,7 +415,6 @@ class HTTPClientRequestTests: XCTestCase {
}

func testPostWithAsyncSequenceWithKnownLength() {
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
XCTAsyncTest {
var request = Request(url: "http://example.com/post")
request.method = .POST
Expand Down Expand Up @@ -602,6 +588,7 @@ class HTTPClientRequestTests: XCTestCase {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
func collect() async throws -> [Element] {
try await self.reduce(into: []) { $0 += CollectionOfOne($1) }
Expand Down
1 change: 1 addition & 0 deletions Tests/AsyncHTTPClientTests/HTTPClientResponseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Logging
import NIOCore
import XCTest

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
final class HTTPClientResponseTests: XCTestCase {
func testSimpleResponse() {
let response = HTTPClientResponse.expectedContentLength(requestMethod: .GET, headers: ["content-length": "1025"], status: .ok)
Expand Down
1 change: 1 addition & 0 deletions Tests/AsyncHTTPClientTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3526,6 +3526,7 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
XCTAssertEqual(.ok, response.status)
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
func testAsyncExecuteWithCustomTLS() async throws {
let httpsBin = HTTPBin(.http1_1(ssl: true))
defer {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AsyncHTTPClientTests/NWWaitingHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import NIOSSL
import NIOTransportServices
import XCTest

@available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *)
@available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
class NWWaitingHandlerTests: XCTestCase {
class MockRequester: HTTPConnectionRequester {
var waitingForConnectivityCalled = false
Expand Down
Loading