Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glbrntt committed Jan 17, 2025
1 parent 986c582 commit 1bb72b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Tests/GRPCNIOTransportHTTP2Tests/ControlService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ extension ControlService {
}

private func clientRemotePeerInfo<T>(request: StreamingServerRequest<T>) -> String {
request.metadata[stringValues: "remotePeer"].first(where: { _ in true })!
request.metadata[stringValues: "remotePeer"].first(where: { _ in true }) ?? "<missing>"
}

private func clientLocalPeerInfo<T>(request: StreamingServerRequest<T>) -> String {
request.metadata[stringValues: "localPeer"].first(where: { _ in true })!
request.metadata[stringValues: "localPeer"].first(where: { _ in true }) ?? "<missing>"
}

private func handle(
Expand Down
12 changes: 8 additions & 4 deletions Tests/GRPCNIOTransportHTTP2Tests/HTTP2TransportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,13 @@ final class HTTP2TransportTests: XCTestCase {
compression: CompressionAlgorithm,
enabledCompression: CompressionAlgorithmSet
) throws -> GRPCClient<NIOClientTransport> {
let transport: NIOClientTransport

switch kind {
case .posix:
var serviceConfig = ServiceConfig()
serviceConfig.loadBalancingConfig = [.roundRobin]
let transport = try HTTP2ClientTransport.Posix(
let posix = try HTTP2ClientTransport.Posix(
target: target,
transportSecurity: .plaintext,
config: .defaults {
Expand All @@ -215,13 +217,13 @@ final class HTTP2TransportTests: XCTestCase {
},
serviceConfig: serviceConfig
)
return GRPCClient(transport: NIOClientTransport(transport))
transport = NIOClientTransport(posix)

case .niots:
#if canImport(Network)
var serviceConfig = ServiceConfig()
serviceConfig.loadBalancingConfig = [.roundRobin]
let transport = try HTTP2ClientTransport.TransportServices(
let transportServices = try HTTP2ClientTransport.TransportServices(
target: target,
transportSecurity: .plaintext,
config: .defaults {
Expand All @@ -230,11 +232,13 @@ final class HTTP2TransportTests: XCTestCase {
},
serviceConfig: serviceConfig
)
return GRPCClient(transport: NIOClientTransport(transport))
transport = NIOClientTransport(transportServices)
#else
throw XCTSkip("Transport not supported on this platform")
#endif
}

return GRPCClient(transport: transport, interceptors: [PeerInfoClientInterceptor()])
}

func testUnaryOK() async throws {
Expand Down

0 comments on commit 1bb72b8

Please sign in to comment.