diff options
author | Santiago M. Mola <santi@mola.io> | 2016-11-07 10:52:45 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-11-07 10:52:45 +0100 |
commit | f6ed7424cbf33c7013332d7e95b4262a4bc4a523 (patch) | |
tree | eec671194e8a80744cd8bc9ee51d2cba0d406344 /utils | |
parent | 1b2f95c971a2492f012db76bd49a948c2691c9bd (diff) | |
download | go-git-f6ed7424cbf33c7013332d7e95b4262a4bc4a523.tar.gz |
utils/fs: added test for open-read-seek. (#117)v4.0.0-rc3
Previously we tested only seek on created files,
not opened.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/fs/test/fs_suite.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/utils/fs/test/fs_suite.go b/utils/fs/test/fs_suite.go index 74301f5..8c413bf 100644 --- a/utils/fs/test/fs_suite.go +++ b/utils/fs/test/fs_suite.go @@ -185,7 +185,7 @@ func (s *FilesystemSuite) testReadClose(c *C, f File, content string) { c.Assert(f.Close(), IsNil) } -func (s *FilesystemSuite) TestFileReadSeek(c *C) { +func (s *FilesystemSuite) TestFileCreateReadSeek(c *C) { f, err := s.Fs.Create("foo") c.Assert(err, IsNil) @@ -203,6 +203,29 @@ func (s *FilesystemSuite) TestFileReadSeek(c *C) { c.Assert(f.Close(), IsNil) } +func (s *FilesystemSuite) TestFileOpenReadSeek(c *C) { + f, err := s.Fs.Create("foo") + c.Assert(err, IsNil) + + n, err := f.Write([]byte("0123456789abcdefghijklmnopqrstuvwxyz")) + c.Assert(err, IsNil) + c.Assert(n, Equals, 36) + + c.Assert(f.Close(), IsNil) + + f, err = s.Fs.Open("foo") + c.Assert(err, IsNil) + + p, err := f.Seek(10, io.SeekStart) + c.Assert(err, IsNil) + c.Assert(int(p), Equals, 10) + + all, err := ioutil.ReadAll(f) + c.Assert(err, IsNil) + c.Assert(string(all), Equals, "abcdefghijklmnopqrstuvwxyz") + c.Assert(f.Close(), IsNil) +} + func (s *FilesystemSuite) TestFileCloseTwice(c *C) { f, err := s.Fs.Create("foo") c.Assert(err, IsNil) |