Merge pull request #732 from pjbgf/umask-fix

Fix tests failing in Ubuntu
This commit is contained in:
Max Jonas Werner 2022-05-25 13:11:53 +02:00 committed by GitHub
commit 4909bacc93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -919,6 +919,8 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
resetChmod(tt.dir, 0o755, 0o644)
r := &GitRepositoryReconciler{
EventRecorder: record.NewFakeRecorder(32),
Storage: testStorage,
@ -2142,3 +2144,24 @@ func TestGitRepositoryReconciler_calculateContentConfigChecksum(t *testing.T) {
artifactCsumModChecksum := r.calculateContentConfigChecksum(obj, artifacts)
g.Expect(artifactModChecksum).ToNot(Equal(artifactCsumModChecksum))
}
func resetChmod(path string, dirMode os.FileMode, fileMode os.FileMode) error {
err := filepath.Walk(path,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() && info.Mode() != dirMode {
os.Chmod(path, dirMode)
} else if !info.IsDir() && info.Mode() != fileMode {
os.Chmod(path, fileMode)
}
return nil
})
if err != nil {
return fmt.Errorf("cannot reset file permissions: %v", err)
}
return nil
}