From b903bd29572046ce2f52d7ea8ce569f277fef34a Mon Sep 17 00:00:00 2001 From: Junjie Qian Date: Mon, 15 May 2017 13:47:14 -0700 Subject: [PATCH] ZipFile: Tests for functions with zipfile --- Zip_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Zip_test.go b/Zip_test.go index c46bd6d..10711e3 100644 --- a/Zip_test.go +++ b/Zip_test.go @@ -3,6 +3,7 @@ package main import ( + "bazil.org/fuse" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "os" @@ -95,6 +96,29 @@ func TestZipDirReadArchive(t *testing.T) { assert.Nil(t, err) assert.Equal(t, "qux", qux.(*ZipFile).Attrs.Name) assert.Equal(t, uint64(1024), qux.(*ZipFile).Attrs.Size) + + // Test ReadDirAll + entries, err := zipRootDir.ReadDirAll(nil) + assert.Nil(t, err) + assert.Equal(t, 2, len(entries)) // Number of subdirs and files + + // Test ZipFile Attr + fuseAttr := &fuse.Attr{} + err = b.Attr(nil, fuseAttr) + assert.Nil(t, err) + assert.Equal(t, uint64(4321), fuseAttr.Size) + + // Test ZipFile Open + zipFileHandle, err := b.(*ZipFile).Open(nil, &fuse.OpenRequest{}, &fuse.OpenResponse{}) + assert.Nil(t, err) + + // Test ZipFile Read + err = zipFileHandle.(*ZipFileHandle).Read(nil, &fuse.ReadRequest{Size: 10}, &fuse.ReadResponse{}) + assert.Nil(t, err) + + // Test ZipFile Release + err = zipFileHandle.(*ZipFileHandle).Release(nil, &fuse.ReleaseRequest{}) + assert.Nil(t, err) } // ReadSeekCloser adapter for os.File