Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
0901f06b
Commit
0901f06b
authored
Feb 22, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for zipfs.
parent
7c3c1e41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
examplelib/test.zip
examplelib/test.zip
+0
-0
examplelib/zipfs_test.go
examplelib/zipfs_test.go
+66
-0
No files found.
examplelib/test.zip
0 → 100644
View file @
0901f06b
File added
examplelib/zipfs_test.go
0 → 100644
View file @
0901f06b
package
examplelib
import
(
"github.com/hanwen/go-fuse/fuse"
"os"
"testing"
"fmt"
)
func
CheckSuccess
(
e
os
.
Error
)
{
if
e
!=
nil
{
panic
(
fmt
.
Sprintf
(
"Unexpected error: %v"
,
e
))
}
}
func
TestZipFs
(
t
*
testing
.
T
)
{
wd
,
err
:=
os
.
Getwd
()
CheckSuccess
(
err
)
zfs
:=
NewZipFileFuse
(
wd
+
"/test.zip"
)
connector
:=
fuse
.
NewPathFileSystemConnector
(
zfs
)
mountPoint
:=
fuse
.
MakeTempDir
()
state
:=
fuse
.
NewMountState
(
connector
)
state
.
Mount
(
mountPoint
)
go
state
.
Loop
(
false
)
d
,
err
:=
os
.
Open
(
mountPoint
,
os
.
O_RDONLY
,
0
)
CheckSuccess
(
err
)
names
,
err
:=
d
.
Readdirnames
(
-
1
)
CheckSuccess
(
err
)
err
=
d
.
Close
()
CheckSuccess
(
err
)
if
len
(
names
)
!=
2
{
t
.
Error
(
"wrong length"
,
names
)
}
fi
,
err
:=
os
.
Stat
(
mountPoint
+
"/subdir"
)
CheckSuccess
(
err
)
if
!
fi
.
IsDirectory
()
{
t
.
Error
(
"directory type"
,
fi
)
}
fi
,
err
=
os
.
Stat
(
mountPoint
+
"/file.txt"
)
CheckSuccess
(
err
)
if
!
fi
.
IsRegular
()
{
t
.
Error
(
"file type"
,
fi
)
}
f
,
err
:=
os
.
Open
(
mountPoint
+
"/file.txt"
,
os
.
O_RDONLY
,
0
)
CheckSuccess
(
err
)
b
:=
make
([]
byte
,
1024
)
n
,
err
:=
f
.
Read
(
b
)
b
=
b
[
:
n
]
if
string
(
b
[
:
n
])
!=
"hello
\n
"
{
t
.
Error
(
"content fail"
,
b
[
:
n
])
}
f
.
Close
()
state
.
Unmount
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment