...
1# Guide to write test for chariot
2
3- Chariot test is straightforward, kinda like a unit test in a sense where you write functions for case where you expect test to pass and case where you expect it to fail.
4
5- Once you create your test cases, you will provide all necessary variables to make the test, and then verify if there is any error coming back.
6
7- For instances, in `response_test.go`, to test for chariot response, you need to write test for successful rsp `TestChariotSuccessfulResponse` and error rsp `TestChariotErrorResponse`
8
9- You will want to set up all testing environments for both cases. Make sure to plan ahead on what your tests need, like seeding datas, variable that will trigger certain condition,etc.
10
11- For ex: to test chariot response, you will call for `newMockResponsePublisher()` , `newMockPubSubService()` and your `test bucket`.
12
13- Then from there you will create request in order to get response back. Obviously, in successful test you will give the all the correct request in order to get the proper response back and for failing case, you will manipulate your request to give back bad response.
14
15- Once you finish writing your test, hit `run test` right on top of your function (if you use VSCode). If you run into any issue, you can add breakpoints inside your test, and use `debug test` right on top of your function, to the right of `run test` button.
16
17- Alternatively, you can use `bazel` command to run your test ` bazel test //pkg/edge/chariot:chariot_test `
18
19
20- Hope you find this guide and this example from `response_test.go` helps guide you in writing your chariot test
21
22## If you have any further question, please reach out to the platform team via Slack @ #ncr-edge-api and we will be happy to aid you :)
View as plain text