Add API test cases and implement mock service#4
Merged
Nuvindu merged 32 commits intoballerina-platform:mainfrom Feb 24, 2025
Merged
Add API test cases and implement mock service#4Nuvindu merged 32 commits intoballerina-platform:mainfrom
Nuvindu merged 32 commits intoballerina-platform:mainfrom
Conversation
Ensure all endpoints are behaving as expected and documented in the API documentation.
Add mock service for quick testing of the client.bal. This mock service removes the server side dependency for the test cases and ensures they run in a consistant manner.
Update positive and negative test cases for the client to handle certain edge cases. This includes tests for invalid app id and payload with complete settings (i.e. including all optionals). Fix the test cases to deal with the DB delay happening at HubSpot's end. HubSpot requires a delay around a minute to update the settings in the DB. Test cases with method GET fails due to this delay, if it is not accounted for.
Add appId validation to the mock service. Fix correct responses for invalid appId.
Update tests with edge cases
Nuvindu
reviewed
Feb 19, 2025
Nuvindu
reviewed
Feb 19, 2025
Nuvindu
reviewed
Feb 19, 2025
Nuvindu
reviewed
Feb 19, 2025
Nuvindu
reviewed
Feb 19, 2025
Remove the auto-generated comment from mock_service.bal file.
Remove additional parentheses in if conditions in test.bal
Print statement used for checking the type of a response was removed as it is not needed anymore.
Update with formatting fixes
Tests are enabled by default, hence remove the unnecessary enable configuration.
Remove unnecessary test configurations
Adding a delay in the tests could cause intermittent failures if the delay is not sufficient for the particular situation. This commit removes the delay in the live tests for the get method. This will result in couple of test failures in the live tests but consistent test results are achieved.
Add concise test case descriptions with stating the positive or negative scenario.
Previously used for delaying the live server test cases for get requests. Since the delay was removed, this import is no longer needed.
Previously used for delaying the live server test cases for get requests. Since the delay was removed, this import is no longer needed.
Remove delay in tests & Add test descriptions
Nuvindu
reviewed
Feb 23, 2025
Use assertEquals instead of assertTrue to compare the actual and expected values when checking for the response code.
Instead of hard-coded incorrectAppId in the request URL, use a final variable for better readability and maintainability.
Fix hardcoded value and incorrect use of assertTrue
Nuvindu
reviewed
Feb 24, 2025
With this change, configurable variable values can change without needing a recompilation of the source code.
Move all configurable values to Config.toml
Nuvindu
reviewed
Feb 24, 2025
ballerina/tests/test.bal
Outdated
Comment on lines
20
to
25
| configurable string hapikey = ?; | ||
| configurable int appId = ?; | ||
|
|
||
| configurable string liveServerUrl = ?; | ||
| configurable string localServerUrl = ?; | ||
| configurable boolean isLiveServer = ?; |
Contributor
There was a problem hiding this comment.
Let's add default values for these configurable variables
Contributor
Author
There was a problem hiding this comment.
for liveServerUrl I added the actual url, instead of a dummy one. If it needs to be replaced to a dummy one, kindly let me know.
Contributor
There was a problem hiding this comment.
Can you add those default values in the file itself?
Contributor
Author
There was a problem hiding this comment.
As in like this?
configurable string hapikey = "my-key-123";
configurable int appId = 12345;
configurable string liveServerUrl = "https://api.hubapi.com/crm/v3/extensions/videoconferencing/settings";
configurable string localServerUrl = "http://localhost:9090";
configurable boolean isLiveServer = true;
Contributor
There was a problem hiding this comment.
Yeah. As discussed in the meeting
Instead of lengthy name `hubSpotVideoConferencing` for the client, use the simpler name `hubspot`.
Add configurable defaults and rename client
Nuvindu
reviewed
Feb 24, 2025
Nuvindu
approved these changes
Feb 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR adds test cases for API endpoints along with a mock service to simulate responses during testing. The goal is to ensure the API behaves as expected under various conditions, improving overall reliability and test coverage.
Examples
Checklist