ci: Use temporary directory for unit tests

ensure a clean and isolated environment for testing purposes.

Signed-off-by: Mayank Pal <mayankpal9654@gmail.com>

ci: Use temporary directory for unit tests

remove err = os.Mkdir('/etc/ceph-csi-config', 0o600)

Signed-off-by: Mayank Pal <mayankpal9654@gmail.com>

ci: Use temporary directory for unit tests

remove err = os.Mkdir('/etc/ceph-csi-config', 0o600)

Signed-off-by: Mayank Pal <mayankpal9654@gmail.com>

ci: Use temporary directory for unit tests

remove if err

Signed-off-by: Mayank Pal <mayankpal9654@gmail.com>
This commit is contained in:
Mayank Pal 2024-05-18 09:39:44 +05:30 committed by mergify[bot]
parent a8e9d66009
commit 822794c242

View File

@ -243,11 +243,8 @@ func TestReadAffinity_GetReadAffinityMapOptions(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("failed to marshal csi config info %v", err) t.Errorf("failed to marshal csi config info %v", err)
} }
tmpConfPath := util.CsiConfigFile tmpConfPath := t.TempDir() + "/ceph-csi.json"
err = os.Mkdir("/etc/ceph-csi-config", 0o600)
if err != nil {
t.Errorf("failed to create directory %s: %v", "/etc/ceph-csi-config", err)
}
err = os.WriteFile(tmpConfPath, csiConfigFileContent, 0o600) err = os.WriteFile(tmpConfPath, csiConfigFileContent, 0o600)
if err != nil { if err != nil {
t.Errorf("failed to write %s file content: %v", util.CsiConfigFile, err) t.Errorf("failed to write %s file content: %v", util.CsiConfigFile, err)