Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
Kirill Smelkov
jacobsa-fuse
Commits
0b43e993
Commit
0b43e993
authored
Mar 20, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the names SetUp and TearDown so that ogletest doesn't run them.
parent
f099d986
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
samples/hellofs/hello_fs_test.go
samples/hellofs/hello_fs_test.go
+2
-10
samples/testing.go
samples/testing.go
+17
-9
No files found.
samples/hellofs/hello_fs_test.go
View file @
0b43e993
...
...
@@ -22,7 +22,6 @@ import (
"syscall"
"testing"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/samples"
"github.com/jacobsa/fuse/samples/hellofs"
.
"github.com/jacobsa/oglematchers"
...
...
@@ -39,21 +38,14 @@ type HelloFSTest struct {
samples
.
SampleTest
}
var
_
SetUpInterface
=
&
HelloFSTest
{}
var
_
TearDownInterface
=
&
HelloFSTest
{}
func
init
()
{
RegisterTestSuite
(
&
HelloFSTest
{})
}
func
(
t
*
HelloFSTest
)
SetUp
(
ti
*
TestInfo
)
{
fs
:
=
&
hellofs
.
HelloFS
{
t
.
FileSystem
=
&
hellofs
.
HelloFS
{
Clock
:
&
t
.
Clock
,
}
t
.
SampleTest
.
Initialize
(
fs
,
&
fuse
.
MountConfig
{})
}
func
(
t
*
HelloFSTest
)
TearDown
()
{
t
.
SampleTest
.
Destroy
()
t
.
SampleTest
.
SetUp
(
ti
)
}
////////////////////////////////////////////////////////////////////////
...
...
samples/testing.go
View file @
0b43e993
...
...
@@ -23,14 +23,20 @@ import (
"github.com/googlecloudplatform/gcsfuse/timeutil"
"github.com/jacobsa/fuse"
"github.com/jacobsa/ogletest"
"golang.org/x/net/context"
)
// A struct that implements common behavior needed by tests in the samples/
// directory. Use it as an anonymous member of your test fixture, calling its
// Initialize method from your SetUp method and its Destroy method from your
// TearDown method.
// directory. Use it as an embedded field in your test fixture, calling its
// SetUp method from your SetUp method after setting the FileSystem field.
type
SampleTest
struct
{
// The file system under test and the configuration with which it should be
// mounted. These must be set by the user of this type before calling SetUp;
// all the other fields below are set by SetUp itself.
FileSystem
fuse
.
FileSystem
MountConfig
fuse
.
MountConfig
// A context object that can be used for long-running operations.
Ctx
context
.
Context
...
...
@@ -44,10 +50,12 @@ type SampleTest struct {
mfs
*
fuse
.
MountedFileSystem
}
// Mount the supplied file system and initialize the exported fields of the
// struct. Panics on error.
func
(
t
*
SampleTest
)
Initialize
(
fs
fuse
.
FileSystem
,
config
*
fuse
.
MountConfig
)
{
err
:=
t
.
initialize
(
fs
,
config
)
// Mount the supplied file system and initialize the other exported fields of
// the struct. Panics on error.
//
// REQUIRES: t.FileSystem has been set.
func
(
t
*
SampleTest
)
SetUp
(
ti
*
ogletest
.
TestInfo
)
{
err
:=
t
.
initialize
(
t
.
FileSystem
,
&
t
.
MountConfig
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -88,14 +96,14 @@ func (t *SampleTest) initialize(
}
// Unmount the file system and clean up. Panics on error.
func
(
t
*
SampleTest
)
Destroy
()
{
func
(
t
*
SampleTest
)
TearDown
()
{
err
:=
t
.
destroy
()
if
err
!=
nil
{
panic
(
err
)
}
}
// Like
Destroy
, but doesn't panic.
// Like
TearDown
, but doesn't panic.
func
(
t
*
SampleTest
)
destroy
()
(
err
error
)
{
// Was the file system mounted?
if
t
.
mfs
==
nil
{
...
...
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