@@ -2,9 +2,12 @@ package filesystem
22
33import (
44 "bytes"
5+ "fmt"
56 "io"
7+ "net"
68 "os"
79 "path"
10+ "runtime"
811 "testing"
912
1013 "github.com/go-git/go-git/v5/plumbing"
@@ -13,6 +16,7 @@ import (
1316
1417 "github.com/go-git/go-billy/v5"
1518 "github.com/go-git/go-billy/v5/memfs"
19+ "github.com/go-git/go-billy/v5/osfs"
1620 . "gopkg.in/check.v1"
1721)
1822
@@ -196,6 +200,28 @@ func (s *NoderSuite) TestDiffDirectory(c *C) {
196200 c .Assert (a , Equals , merkletrie .Modify )
197201}
198202
203+ func (s * NoderSuite ) TestSocket (c * C ) {
204+ if runtime .GOOS == "windows" {
205+ c .Skip ("socket files do not exist on windows" )
206+ }
207+
208+ td , err := os .MkdirTemp ("" , "socket-test" )
209+ defer os .RemoveAll (td )
210+ c .Assert (err , IsNil )
211+
212+ sock , err := net .ListenUnix ("unix" , & net.UnixAddr {Name : fmt .Sprintf ("%s/socket" , td ), Net : "unix" })
213+ c .Assert (err , IsNil )
214+ defer sock .Close ()
215+
216+ fsA := osfs .New (td )
217+ WriteFile (fsA , "foo" , []byte ("foo" ), 0644 )
218+
219+ noder := NewRootNode (fsA , nil )
220+ childs , err := noder .Children ()
221+ c .Assert (err , IsNil )
222+ c .Assert (childs , HasLen , 1 )
223+ }
224+
199225func WriteFile (fs billy.Filesystem , filename string , data []byte , perm os.FileMode ) error {
200226 f , err := fs .OpenFile (filename , os .O_WRONLY | os .O_CREATE | os .O_TRUNC , perm )
201227 if err != nil {
0 commit comments