aboutsummaryrefslogtreecommitdiffstats
path: root/utils/fs/test/fs_suite.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/fs/test/fs_suite.go')
-rw-r--r--utils/fs/test/fs_suite.go25
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)