PR changes
This commit is contained in:
parent
d597722cca
commit
988d42102c
|
|
@ -18,7 +18,7 @@ import XCTest
|
|||
import Network
|
||||
import NIOCore
|
||||
import NIOEmbedded
|
||||
@testable import NIOTransportServices
|
||||
import NIOTransportServices
|
||||
import NIOConcurrencyHelpers
|
||||
import Foundation
|
||||
|
||||
|
|
@ -384,11 +384,11 @@ final class NIOTSBootstrapTests: XCTestCase {
|
|||
|
||||
func channelActive(context: ChannelHandlerContext) {
|
||||
self.connectionPromise.succeed()
|
||||
context.fireChannelActive()
|
||||
}
|
||||
}
|
||||
|
||||
let group = NIOTSEventLoopGroup(loopCount: 1)
|
||||
|
||||
try await withEventLoopGroup { group in
|
||||
let configuratorListenerCounter = NIOLockedValueBox(0)
|
||||
let configuratorConnectionCounter = NIOLockedValueBox(0)
|
||||
let waitForConnectionHandler = WaitForConnectionHandler(
|
||||
|
|
@ -422,8 +422,7 @@ final class NIOTSBootstrapTests: XCTestCase {
|
|||
|
||||
XCTAssertEqual(2, configuratorListenerCounter.withLockedValue { $0 })
|
||||
XCTAssertEqual(1, configuratorConnectionCounter.withLockedValue { $0 })
|
||||
|
||||
try await group.shutdownGracefully()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,11 +245,11 @@ final class NIOTSDatagramConnectionChannelTests: XCTestCase {
|
|||
|
||||
func channelActive(context: ChannelHandlerContext) {
|
||||
self.connectionPromise.succeed()
|
||||
context.fireChannelActive()
|
||||
}
|
||||
}
|
||||
|
||||
let group = NIOTSEventLoopGroup(loopCount: 1)
|
||||
|
||||
try await withEventLoopGroup { group in
|
||||
let configuratorListenerCounter = NIOLockedValueBox(0)
|
||||
let configuratorConnectionCounter = NIOLockedValueBox(0)
|
||||
let waitForConnectionHandler = WaitForConnectionHandler(
|
||||
|
|
@ -288,8 +288,7 @@ final class NIOTSDatagramConnectionChannelTests: XCTestCase {
|
|||
|
||||
XCTAssertEqual(2, configuratorListenerCounter.withLockedValue { $0 })
|
||||
XCTAssertEqual(1, configuratorConnectionCounter.withLockedValue { $0 })
|
||||
|
||||
try await group.shutdownGracefully()
|
||||
}
|
||||
}
|
||||
|
||||
func testCanExtractTheConnection() throws {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
//
|
||||
// Copyright (c) 2017-2025 Apple Inc. and the SwiftNIO project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import NIOCore
|
||||
import NIOTransportServices
|
||||
|
||||
func withEventLoopGroup(_ test: (EventLoopGroup) async throws -> Void) async rethrows {
|
||||
let group = NIOTSEventLoopGroup()
|
||||
do {
|
||||
try await test(group)
|
||||
} catch {
|
||||
try await group.shutdownGracefully()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue