Skip to content

Commit

Permalink
test: indifference to comma separated header spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Sep 26, 2024
1 parent dfb0664 commit 38d7253
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import software.amazon.smithy.utils.IoUtils;
import software.amazon.smithy.utils.MapUtils;
import software.amazon.smithy.utils.Pair;
import software.amazon.smithy.utils.SetUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
Expand All @@ -91,6 +92,9 @@ public final class HttpProtocolTestGenerator implements Runnable {

private static final Logger LOGGER = Logger.getLogger(HttpProtocolTestGenerator.class.getName());
private static final String TEST_CASE_FILE_TEMPLATE = "test/functional/%s.spec.ts";
private static final Set<String> IGNORE_COMMA_SPACING = SetUtils.of(
"content-encoding"
);

private final TypeScriptSettings settings;
private final Model model;
Expand Down Expand Up @@ -517,7 +521,17 @@ private void writeHttpHeaderAssertions(HttpMessageTestCase testCase) {
testCase.getHeaders().forEach((header, value) -> {
header = header.toLowerCase();
writer.write("expect(r.headers[$S]).toBeDefined();", header);
writer.write("expect(r.headers[$S]).toBe($S);", header, value);
if (IGNORE_COMMA_SPACING.contains(header) && value.contains(",")) {
writer.write("""
expect(
r.headers[$S].replaceAll(", ", ",")
).toBe(
$S.replaceAll(", ", ",")
);
""", header, value);
} else {
writer.write("expect(r.headers[$S]).toBe($S);", header, value);
}
});
writer.write("");
}
Expand Down

0 comments on commit 38d7253

Please sign in to comment.