Add missing availability guards in tests (#2596)

# Motivation
We were missing a few availability guards in our tests which causes compile time errors when building for older Darwin SDKs.

# Modification
This PR adds the missing availability guards.
This commit is contained in:
Franz Busch authored and GitHub committed 2023-11-24 07:53:55 -08:00
1 parent 703ee9172b
commit 80249029d0
7 files changed
+11

No files matched your search

@@ -15,6 +15,7 @@
@testable import NIOCore
import XCTest
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class AsyncChannelInboundStreamTests: XCTestCase {
func testTestingStream() async throws {
let (stream, source) = NIOAsyncChannelInboundStream<Int>.makeTestingStream()
@@ -15,6 +15,7 @@
@testable import NIOCore
import XCTest
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class AsyncChannelOutboundWriterTests: XCTestCase {
func testTestingWriter() async throws {
let (writer, sink) = NIOAsyncChannelOutboundWriter<Int>.makeTestingWriter()
@@ -425,6 +425,7 @@ private final class CloseSuppressor: ChannelOutboundHandler, RemovableChannelHan
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension NIOAsyncTestingChannel {
fileprivate func closeIgnoringSuppression() async throws {
try await self.pipeline.context(handlerType: CloseSuppressor.self).flatMap {
@@ -455,6 +456,7 @@ private enum TestError: Error {
case bang
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension Array {
fileprivate init<AS: AsyncSequence>(_ sequence: AS) async throws where AS.Element == Self.Element {
self = []
@@ -15,6 +15,7 @@
import NIOCore
import XCTest
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBackPressureStrategy, @unchecked Sendable {
enum Event {
case didYield
@@ -48,6 +49,7 @@ final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBa
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class MockNIOBackPressuredStreamSourceDelegate: NIOAsyncSequenceProducerDelegate, @unchecked Sendable {
enum Event {
case produceMore
@@ -673,6 +675,7 @@ fileprivate func XCTAssertEqualWithoutAutoclosure<T>(
XCTAssertEqual(expression1, expression2, message(), file: file, line: line)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension AsyncSequence {
/// Collect all elements in the sequence into an array.
fileprivate func collect() async rethrows -> [Element] {
@@ -850,6 +850,7 @@ fileprivate func XCTAssertEqualWithoutAutoclosure<T>(
XCTAssertEqual(expression1, expression2, message(), file: file, line: line)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension AsyncSequence {
/// Collect all elements in the sequence into an array.
fileprivate func collect() async rethrows -> [Element] {
@@ -191,6 +191,7 @@ private final class AddressedEnvelopingHandler: ChannelDuplexHandler {
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class AsyncChannelBootstrapTests: XCTestCase {
enum NegotiationResult {
case string(NIOAsyncChannel<String, String>)
@@ -1358,6 +1359,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension AsyncStream {
fileprivate static func makeStream(
of elementType: Element.Type = Element.self,
@@ -61,6 +61,7 @@ final class SerialExecutorTests: XCTestCase {
try await self._testBasicExecutorFitsOnEventLoop(loop1: loops[0], loop2: loops[1])
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
func testBasicExecutorFitsOnEventLoop_AsyncTestingEventLoop() async throws {
let loop1 = NIOAsyncTestingEventLoop()
let loop2 = NIOAsyncTestingEventLoop()