Skip to content

Commit

Permalink
Merge pull request ballerina-platform#6 from prakanth97/fix_bug_in_test
Browse files Browse the repository at this point in the history
Fix bug in stream_namespace_test
  • Loading branch information
prakanth97 authored Nov 6, 2023
2 parents b1e8bd9 + 19f57ac commit 48a8874
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions ballerina/tests/stream_namespace_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@ type CustomerFullNS record {
prefix: "cust"
}
type CustomersFullNS record {
CustomerFull[] customer;
CustomerFullNS[] customer;
};

@Name {value: "invoice"}
type InvoiceFullNS record {
ProductsFull products;
CustomersFull customers;
ProductsFullNS products;
CustomersFullNS customers;
};

# Test namespaces & prefixes with a record including all fields with annotations.
#
# + return - return error on failure, otherwise nil.
@test:Config
function testNamespaceInvoiceFull() returns error? {
stream<byte[], error?> dataStream = check io:fileReadBlocksAsStream("tests/resources/default_namespaced_invoice.xml");
stream<byte[], error?> dataStream = check io:fileReadBlocksAsStream("tests/resources/namespaced_invoice.xml");
InvoiceFullNS invoice = check fromXmlStringWithType(dataStream);

test:assertEquals(invoice.length(), 2, "Invoice count mismatched");
Expand All @@ -143,9 +143,7 @@ function testNamespaceInvoiceFull() returns error? {
test:assertEquals(invoice.products.product[0].length(), 5, "Product 1 field count mismatched");
test:assertEquals(invoice.products.product[0].id, 1);
test:assertEquals(invoice.products.product[0].name, "Product 1");
test:assertEquals(invoice.products.product[0].description, string `This is the description for
Product 1.
`);
test:assertEquals(invoice.products.product[0].description, string `This is the description for Product 1.`);
test:assertEquals(invoice.products.product[0].price.length(), 2, "Price 1 price field count mismatched");
test:assertEquals(invoice.products.product[0].price.\#content, 57.70d);
test:assertEquals(invoice.products.product[0].price.currency, "USD");
Expand All @@ -154,9 +152,7 @@ function testNamespaceInvoiceFull() returns error? {
test:assertEquals(invoice.products.product[1].length(), 5, "Product 2 field count mismatched");
test:assertEquals(invoice.products.product[1].id, 2);
test:assertEquals(invoice.products.product[1].name, "Product 2");
test:assertEquals(invoice.products.product[1].description, string `This is the description for
Product 2.
`);
test:assertEquals(invoice.products.product[1].description, string `This is the description for Product 2.`);
test:assertEquals(invoice.products.product[0].price.length(), 2, "Price 1 price field count mismatched");
test:assertEquals(invoice.products.product[1].price.\#content, 6312.36d);
test:assertEquals(invoice.products.product[1].price.currency, "LKR");
Expand Down

0 comments on commit 48a8874

Please sign in to comment.