github.com/mgoltzsche/ctnr@v0.7.1-alpha/pkg/fs/source/sourcesymlink_test.go (about) 1 package source 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/mgoltzsche/ctnr/pkg/fs" 8 "github.com/mgoltzsche/ctnr/pkg/idutils" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestSourceSymlink(t *testing.T) { 13 mtime, err := time.Parse(time.RFC3339, "2018-01-23T01:01:42Z") 14 require.NoError(t, err) 15 mtime = time.Unix(mtime.Unix(), 900000000) 16 atime, err := time.Parse(time.RFC3339, "2018-01-23T01:02:42Z") 17 require.NoError(t, err) 18 testee := sourceSymlink{fs.FileAttrs{Symlink: "../symlinkdest", UserIds: idutils.UserIds{1, 33}, FileTimes: fs.FileTimes{Atime: atime, Mtime: mtime}}} 19 a := testee.Attrs() 20 if a.NodeType != fs.TypeSymlink { 21 t.Error("type != TypeSymlink") 22 t.FailNow() 23 } 24 if a.Symlink == "" { 25 t.Error("symlink does not provide destination path") 26 t.FailNow() 27 } 28 29 // Test write 30 assertSourceWriteWithHardlinkSupport(t, &testee, "/file type=symlink usr=1:33 link=../symlinkdest mtime=1516669302 atime=1516669362") 31 }