test: check cleanup errors (#22)

This commit is contained in:
2025-07-13 14:08:23 +03:00
committed by GitHub
parent ef2296d45e
commit b017814c6d
4 changed files with 57 additions and 13 deletions

View File

@@ -16,7 +16,11 @@ func TestDefaultConfig(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create temp directory: %v", err)
}
defer os.RemoveAll(tmpDir)
defer func() {
if err := os.RemoveAll(tmpDir); err != nil {
t.Fatalf("cleanup failed: %v", err)
}
}()
// Point Viper to the temp directory with no config file.
originalConfigPaths := viper.ConfigFileUsed()
@@ -46,7 +50,11 @@ func TestLoadConfigFile(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create temp directory: %v", err)
}
defer os.RemoveAll(tmpDir)
defer func() {
if err := os.RemoveAll(tmpDir); err != nil {
t.Fatalf("cleanup failed: %v", err)
}
}()
// Prepare a minimal config file
configContent := []byte(`---