Skip to content

Commit

Permalink
Fix #141 comparing symlink permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicLavery committed Jan 7, 2022
1 parent 7fe928e commit aca5a3c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
30 changes: 30 additions & 0 deletions fs/manifest_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// +build darwin

package fs

import (
"os"
"syscall"
)

const (
defaultRootDirMode = os.ModeDir | 0700
defaultSymlinkMode = os.ModeSymlink | 0755
)

func newResourceFromInfo(info os.FileInfo) resource {
statT := info.Sys().(*syscall.Stat_t)
return resource{
mode: info.Mode(),
uid: statT.Uid,
gid: statT.Gid,
}
}

func (p *filePath) SetMode(mode os.FileMode) {
p.file.mode = mode
}

func (p *directoryPath) SetMode(mode os.FileMode) {
p.directory.mode = mode | os.ModeDir
}
11 changes: 11 additions & 0 deletions fs/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ func TestManifestFromDir(t *testing.T) {
actual.root.items["s"].(*directory).items["k"].(*file).content.Close()
}

func TestSymlinks(t *testing.T) {
rootDirectory := NewDir(t, "root",
WithFile("foo.txt", "foo"),
WithSymlink("foo.link", "foo.txt"))
defer rootDirectory.Remove()
expected := Expected(t,
WithFile("foo.txt", "foo"),
WithSymlink("foo.link", rootDirectory.Join("foo.txt")))
assert.Assert(t, Equal(rootDirectory.Path(), expected))
}

var cmpManifest = cmp.Options{
cmp.AllowUnexported(Manifest{}, resource{}, file{}, symlink{}, directory{}),
cmp.Comparer(func(x, y io.ReadCloser) bool {
Expand Down
2 changes: 1 addition & 1 deletion fs/manifest_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !windows
// +build !windows,!darwin

package fs

Expand Down

0 comments on commit aca5a3c

Please sign in to comment.