Skip to content

Commit

Permalink
Fix metadata check in interop tests
Browse files Browse the repository at this point in the history
Motivation:

The custom-metadata interop tests checks the underlying element is a
decoded `.binary` element. This is isn't guaranteed for binary metadata
values as the transport may not decode them. The test should instead
check that the _binary values_ for the key are as expected.

Modifications:

- Use `subscript(binaryValues:)` and `subscript(stringValues:)`

Result:

More correct test
  • Loading branch information
glbrntt committed Feb 25, 2025
1 parent 35eba4e commit 222a82f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/GRPCInteropTests/InteroperabilityTestCases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,13 @@ struct CustomMetadata: InteroperabilityTest {
let trailingMetadataValue: [UInt8] = [0xAB, 0xAB, 0xAB]

func checkInitialMetadata(_ metadata: Metadata) throws {
let values = metadata[self.initialMetadataName]
try assertEqual(Array(values), [.string(self.initialMetadataValue)])
let values = metadata[stringValues: self.initialMetadataName]
try assertEqual(Array(values), [self.initialMetadataValue])
}

func checkTrailingMetadata(_ metadata: Metadata) throws {
let values = metadata[self.trailingMetadataName]
try assertEqual(Array(values), [.binary(self.trailingMetadataValue)])
let values = metadata[binaryValues: self.trailingMetadataName]
try assertEqual(Array(values), [self.trailingMetadataValue])
}

func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
Expand Down

0 comments on commit 222a82f

Please sign in to comment.