Skip to content

Commit

Permalink
Add negative test for name mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK committed Sep 23, 2024
1 parent d59f00e commit 3b117aa
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ballerina-tests/http-misc-tests/tests/http_header_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,21 @@ function testPassthruWithBody() returns error? {
}

type Headers record {|
@http:Header { name: "X-API-VERSION" }
@http:Header {name: "X-API-VERSION"}
string apiVersion;
@http:Header { name: "X-REQ-ID" }
@http:Header {name: "X-REQ-ID"}
int reqId;
@http:Header { name: "X-IDS" }
@http:Header {name: "X-IDS"}
float[] ids;
|};

type HeadersNegative record {|
@http:Header
string header1;
@http:Header {name: ()}
string header2;
|};

@test:Config {}
function testGetHeadersMethod() {
Headers headers = {apiVersion: "v1", reqId: 123, ids: [1.0, 2.0, 3.0]};
Expand All @@ -296,6 +303,12 @@ function testGetHeadersMethod() {
test:assertEquals(http:getHeaderMap(headers), expectedHeaderMap, "Header map is not as expected");
}

@test:Config {}
function testGetHeadersMethodNegative() {
HeadersNegative headers = {header1: "header1", header2: "header2"};
test:assertEquals(http:getHeaderMap(headers), headers, "Header map is not as expected");
}

type Queries record {|
@http:Query { name: "XName" }
string name;
Expand Down

0 comments on commit 3b117aa

Please sign in to comment.