Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
b685f92c
Commit
b685f92c
authored
Jan 14, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(fsrepo): InitIdempotence, NilRemoval, ReopeningDisallowed
parent
ece9ed09
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
repo/fsrepo/fsrepo_test.go
repo/fsrepo/fsrepo_test.go
+24
-0
No files found.
repo/fsrepo/fsrepo_test.go
View file @
b685f92c
...
...
@@ -15,6 +15,18 @@ func testRepoPath(p string, t *testing.T) string {
return
name
}
func
TestInitIdempotence
(
t
*
testing
.
T
)
{
path
:=
testRepoPath
(
""
,
t
)
for
i
:=
0
;
i
<
10
;
i
++
{
AssertNil
(
Init
(
path
,
&
config
.
Config
{}),
t
,
"multiple calls to init should succeed"
)
}
}
func
TestRemove
(
t
*
testing
.
T
)
{
path
:=
testRepoPath
(
"foo"
,
t
)
AssertNil
(
Remove
(
path
),
t
,
"should be able to remove after closed"
)
}
func
TestCannotRemoveIfOpen
(
t
*
testing
.
T
)
{
path
:=
testRepoPath
(
"TestCannotRemoveIfOpen"
,
t
)
AssertNil
(
Init
(
path
,
&
config
.
Config
{}),
t
,
"should initialize successfully"
)
...
...
@@ -25,6 +37,18 @@ func TestCannotRemoveIfOpen(t *testing.T) {
AssertNil
(
Remove
(
path
),
t
,
"should be able to remove after closed"
)
}
func
TestCannotBeReopened
(
t
*
testing
.
T
)
{
path
:=
testRepoPath
(
""
,
t
)
AssertNil
(
Init
(
path
,
&
config
.
Config
{}),
t
)
r
:=
At
(
path
)
AssertNil
(
r
.
Open
(),
t
)
AssertNil
(
r
.
Close
(),
t
)
AssertErr
(
r
.
Open
(),
t
,
"shouldn't be possible to re-open the repo"
)
// mutable state is the enemy. Take Close() as an opportunity to reduce
// entropy. Callers ought to start fresh with a new handle by calling `At`.
}
func
TestCanManageReposIndependently
(
t
*
testing
.
T
)
{
pathA
:=
testRepoPath
(
"a"
,
t
)
pathB
:=
testRepoPath
(
"b"
,
t
)
...
...
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