Testing endpoints
Let's learn how to test endpoints:
- during development;
- and after publication.
Testing during development
The Workspace provides an easy way to test endpoints during development.
For instance, suppose you want to test the following endpoint during development:
main(stock: int) =
let
data = MySQL.InferAndRead("mysql001", "products")
in
Collection.Filter(data, x -> x.stockcount < stock)
This endpoint requires a argument. Therefore, you cannot press the "Play" button in the IDE because there is no argument. To do so, just add a line at the end with the value you want to test as in:
main(stock: int) =
let
data = MySQL.InferAndRead("mysql001", "products")
in
Collection.Filter(data, x -> x.stockcount < stock)
// The following will be executed when you press "Play" button
main(5)
You can now press the "Play" button to see the result when the argument "5" is passed. You can change the value for others and test accordingly.
Note that the last line will be ignored during publication, because endpoints will always call a function called main
and ignore other code.
Testing after publication
Once APIs have been published, it is best to test them. The easiest way is to use a command-line tool such as cURL. Refer to the Invocation Details section of the Catalog console.
More powerful testing with GitHub integration
These testing features are sufficient for simple cases, but RAW supports more powerful testing including full CI/CD integration.
Refer to the GitHub integration to learn how to use GitHub Branches and Pull Requests to test endpoints without affecting endpoints deployed in production.