Skip to content

Commit 4909bac

Browse files
authored
Merge pull request fluxcd#732 from pjbgf/umask-fix
Fix tests failing in Ubuntu
2 parents 6e768b3 + 49232cb commit 4909bac

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

controllers/gitrepository_controller_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
919919
t.Run(tt.name, func(t *testing.T) {
920920
g := NewWithT(t)
921921

922+
resetChmod(tt.dir, 0o755, 0o644)
923+
922924
r := &GitRepositoryReconciler{
923925
EventRecorder: record.NewFakeRecorder(32),
924926
Storage: testStorage,
@@ -2142,3 +2144,24 @@ func TestGitRepositoryReconciler_calculateContentConfigChecksum(t *testing.T) {
21422144
artifactCsumModChecksum := r.calculateContentConfigChecksum(obj, artifacts)
21432145
g.Expect(artifactModChecksum).ToNot(Equal(artifactCsumModChecksum))
21442146
}
2147+
2148+
func resetChmod(path string, dirMode os.FileMode, fileMode os.FileMode) error {
2149+
err := filepath.Walk(path,
2150+
func(path string, info os.FileInfo, err error) error {
2151+
if err != nil {
2152+
return err
2153+
}
2154+
2155+
if info.IsDir() && info.Mode() != dirMode {
2156+
os.Chmod(path, dirMode)
2157+
} else if !info.IsDir() && info.Mode() != fileMode {
2158+
os.Chmod(path, fileMode)
2159+
}
2160+
return nil
2161+
})
2162+
if err != nil {
2163+
return fmt.Errorf("cannot reset file permissions: %v", err)
2164+
}
2165+
2166+
return nil
2167+
}

0 commit comments

Comments
 (0)