I am working on a Go project using Visual Studio Code as my IDE and Doppler for managing secrets. Normally, to run my application with Doppler secrets, I use the following command:
doppler run -- go run main.go
However, I encounter a challenge when trying to run my Go tests. The default test run commands in Visual Studio Code are not prefixed with doppler run, which means my tests cannot access the secrets managed by Doppler.
Is there a way to configure Visual Studio Code to automatically use doppler run when executing Go tests? This is essential for ensuring that my tests have access to the necessary environment variables set by Doppler.
I've considered modifying the test configuration in launch.json, but I am unsure how to integrate Doppler into this process. Specifically, I am looking for a solution that allows me to run tests from the Visual Studio Code interface (e.g., using the 'Run Test' or 'Debug Test' options in the editor) with Doppler secrets injected.
Any suggestions or examples of how to set this up would be greatly appreciated.
I couldn't find any examples in the documentation of overriding the default test command, like I have done previously with the jest vscode extension
Assuming you're using the Go extension for VS Code and want to continue doing your tests through it, I think not. It contributes a
go.testFlagssetting, but I didn't see a setting for adding a "wrapper command". What you could try do is write a task or a launch config that runs the specific command you want. You may find variables of use if you want to make those tasks more reusable.