Clear go test environment variables
Overview
Ensure that parent environment variables don't influence tests by making sure they're cleared before invoking go test
. By default when you run go test
it will inherit all the environment variables that are available in the system. In CI this means that it will inherit the predefined variables and also any CI/CD variables you have configured.
Since we are running tests for gitlab-runner
which means running real jobs inside of our CI environment it (using gitlab-runner to test gitlab-runner) it means that we depend on these environment variables to be a specific value and we don't want the external CI service influencing our tests nor mangling the values of the system. When invoking go test
we need to make sure only the necessary variables are passed.