fix cmd/tofu tests by using t.Chdir instead of os.Chdir (#3285)

Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
Diógenes Fernandes
2025-09-17 12:10:13 -03:00
committed by GitHub
parent 197135b4af
commit ff9657f5b7

View File

@@ -100,17 +100,11 @@ func TestProviderSource(t *testing.T) {
// Setup test environment
originalWorkingDir, overrideWd := tt.setupFunc(t)
err := os.Chdir(originalWorkingDir)
if err != nil {
t.Fatalf("Failed to change to original working directory: %v", err)
}
t.Chdir(originalWorkingDir)
// If we have an override directory, change to it (simulating -chdir behavior)
if overrideWd != "" {
err := os.Chdir(overrideWd)
if err != nil {
t.Fatalf("Failed to change to override directory: %v", err)
}
t.Chdir(overrideWd)
}
// Create a mock disco service