I am writing e2e tests for a command line app where I have to do file manipulation (such as cp
, mv
, rm
, touch
, and mkdir
). The tests can execute just fine in my local environment. The problem occurs when they are executed on the server across platforms, where the file manipulation gets interfered with each other. Questions are:
Sorry this is more of a general and specific question at the same time. Doubt there will be a perfect answer but would love to hear some suggestions and opinions as I am new in both Go and testing. Appreciate the help!
There is nothing wrong in using OS commands in your code otherwise these will not be available to be used, although it may be incompatible depending on the target environment and as you are facing now may have some restrictions. One tool that can work as a layer to the file commands is Afero, where you can use it even to simulate in-memory operations and S3 resources.