diff options
author | James Fargher <jfargher@gitlab.com> | 2023-02-07 06:38:49 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2023-02-08 22:50:38 +0300 |
commit | 5cf02f580e6eafb00c93631803d9627e6a579e83 (patch) | |
tree | 8675c12376a25ee2a42fcbec12f9bbccc3d777dc /packed_binaries_test.go | |
parent | 3060313e355e2fe711f6964a44ae5335fb68a76c (diff) |
Extract file and executable permissions
Bulk update all file and executable permissions to use the new perm
package.
Strictly speaking changing os.ModePerm to perm.PublicFile is a
permission change (it goes from executable to normal), but since
ModePerm is only used in tests this should be safe.
Diffstat (limited to 'packed_binaries_test.go')
-rw-r--r-- | packed_binaries_test.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/packed_binaries_test.go b/packed_binaries_test.go index d904ab28b..1c9941305 100644 --- a/packed_binaries_test.go +++ b/packed_binaries_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/v15/internal/helper/perm" ) func TestUnpackAuxiliaryBinaries_success(t *testing.T) { @@ -21,7 +22,7 @@ func TestUnpackAuxiliaryBinaries_success(t *testing.T) { for _, entry := range entries { fileInfo, err := entry.Info() require.NoError(t, err) - require.Equal(t, fileInfo.Mode(), os.FileMode(0o700), "expected the owner to have rwx permissions on the unpacked binary") + require.Equal(t, fileInfo.Mode(), perm.PrivateExecutable, "expected the owner to have rwx permissions on the unpacked binary") sourceBinary, err := os.ReadFile(filepath.Join(buildDir, fileInfo.Name())) require.NoError(t, err) @@ -37,7 +38,7 @@ func TestUnpackAuxiliaryBinaries_alreadyExists(t *testing.T) { destinationDir := t.TempDir() existingFile := filepath.Join(destinationDir, "gitaly-hooks") - require.NoError(t, os.WriteFile(existingFile, []byte("existing file"), os.ModePerm)) + require.NoError(t, os.WriteFile(existingFile, []byte("existing file"), perm.PublicFile)) err := UnpackAuxiliaryBinaries(destinationDir) require.EqualError(t, err, fmt.Sprintf(`open %s: file exists`, existingFile), "expected unpacking to fail if destination binary already existed") |