Skip to content

Add API endpoint test cases and implement mock service#5

Merged
Nuvindu merged 10 commits intoballerina-platform:mainfrom
ShiwanthaH:main
Feb 22, 2025
Merged

Add API endpoint test cases and implement mock service#5
Nuvindu merged 10 commits intoballerina-platform:mainfrom
ShiwanthaH:main

Conversation

@ShiwanthaH
Copy link
Contributor

Purpose

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@ShiwanthaH ShiwanthaH changed the title Add API endpoint test cases and mock service Add API endpoint test cases and implement mock service Feb 19, 2025
resource function post batch/update(@http:Payload BatchInputSimplePublicObjectBatchInput payload) returns BatchResponseSimplePublicObject|error {
BatchResponseSimplePublicObject response;

if (payload.inputs[0].id == "invalid-id") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (payload.inputs[0].id == "invalid-id") {
if payload.inputs[0].id == "invalid-id" {

We don't use parentheses for if, for, while statements in Ballerina. Check for other places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed parentheses and updated

}
);

test:assertTrue(response?.total == 0, "Response is not an error");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use assertEquals to compare values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@Nuvindu Nuvindu merged commit cfaaea2 into ballerina-platform:main Feb 22, 2025
2 checks passed
Nuvindu pushed a commit that referenced this pull request Feb 27, 2025
Add example for batch requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants