Implement Bats test for the script with mocks
Create unit tests for upload and google-oauth2 bash script. The tests must mock curl requests to google drive API so that no real google account is required to run the tests.
@labbots So we are going to check if the api is working ?? I don't understand how is that fair for a test, it's more of a google drive api test than upload test. Again, i didn't fully understand your idea.
I thought the purpose of a test script is to test the functionality of the script, which here is uploading files to google drive.
Obviously, we can use credentials safely using github secrets, but need to check if it's fully safe and rational to use
@Akianonymus I was intending to have unit tests rather than integration tests. The purpose of the test is to check the functionality of the functions within the script and not to test external service. In this case we know the output of the google drive API are standard and there is no necessity to actually make calls to google drive API. The response from the API could be mocked for various scenario and tested.
@labbots Ok, understood some of it.
Question, how do we exactly mock it ? do we parse the errors messages, i mean without credentials, it won't tell anything except basic google errors ?
I am not exactly sure how mocking works with bats tests. But usually in other programming languages, you define the output for a method based on the provided input. In our case, we need to mock curl request based on different parameter passed on the curl request and test the functionality. I need to do further research on how this could be achieved with unit tests in bash script.
I propose to use something like this
https://github.com/dylanaraps/pure-bash-bible/blob/master/test.sh