diff --git a/internal/cli/integration_test.go b/internal/cli/integration_test.go index c1a4144..8abe250 100644 --- a/internal/cli/integration_test.go +++ b/internal/cli/integration_test.go @@ -52,8 +52,7 @@ func TestMain(m *testing.M) { // This test serves as both validation and documentation of the program's behavior. func TestSecretManagerIntegration(t *testing.T) { // Enable debug logging to diagnose issues - os.Setenv("GODEBUG", "berlin.sneak.pkg.secret") - defer os.Unsetenv("GODEBUG") + t.Setenv("GODEBUG", "berlin.sneak.pkg.secret") // Reinitialize debug logging to pick up the environment variable change secret.InitDebugLogging() @@ -66,8 +65,7 @@ func TestSecretManagerIntegration(t *testing.T) { tempDir := t.TempDir() // Set environment variables for the test - os.Setenv("SB_SECRET_STATE_DIR", tempDir) - defer os.Unsetenv("SB_SECRET_STATE_DIR") + t.Setenv("SB_SECRET_STATE_DIR", tempDir) // Find the secret binary path (needed for tests that still use exec.Command) wd, err := os.Getwd() @@ -1570,7 +1568,7 @@ func test23ErrorHandling(t *testing.T, tempDir, secretPath, testMnemonic string, cmdOutput, err = cmd.CombinedOutput() assert.Error(t, err, "get without mnemonic should fail") assert.Contains(t, string(cmdOutput), "failed to unlock", "should indicate unlock failure") - os.Setenv("SB_SECRET_MNEMONIC", unsetMnemonic) + t.Setenv("SB_SECRET_MNEMONIC", unsetMnemonic) // Invalid secret names (already tested in test 12)