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-datastore
Commits
27fe4c12
Commit
27fe4c12
authored
Mar 13, 2015
by
Tommi Virtanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement mount Delete
parent
6c898393
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
mount/mount.go
mount/mount.go
+5
-1
mount/mount_test.go
mount/mount_test.go
+37
-0
No files found.
mount/mount.go
View file @
27fe4c12
...
...
@@ -70,7 +70,11 @@ func (d *Datastore) Has(key datastore.Key) (exists bool, err error) {
}
func
(
d
*
Datastore
)
Delete
(
key
datastore
.
Key
)
error
{
return
errors
.
New
(
"TODO"
)
ds
,
k
:=
d
.
lookup
(
key
)
if
ds
==
nil
{
return
datastore
.
ErrNotFound
}
return
ds
.
Delete
(
k
)
}
func
(
d
*
Datastore
)
Query
(
q
query
.
Query
)
(
query
.
Results
,
error
)
{
...
...
mount/mount_test.go
View file @
27fe4c12
...
...
@@ -168,3 +168,40 @@ func TestHas(t *testing.T) {
t
.
Fatalf
(
"wrong value: %v != %v"
,
g
,
e
)
}
}
func
TestDeleteNotFound
(
t
*
testing
.
T
)
{
mapds
:=
datastore
.
NewMapDatastore
()
m
:=
mount
.
New
([]
mount
.
Mount
{
{
Prefix
:
datastore
.
NewKey
(
"/quux"
),
Datastore
:
mapds
},
})
err
:=
m
.
Delete
(
datastore
.
NewKey
(
"/quux/thud"
))
if
g
,
e
:=
err
,
datastore
.
ErrNotFound
;
g
!=
e
{
t
.
Fatalf
(
"expected ErrNotFound, got: %v
\n
"
,
g
)
}
}
func
TestDelete
(
t
*
testing
.
T
)
{
mapds
:=
datastore
.
NewMapDatastore
()
m
:=
mount
.
New
([]
mount
.
Mount
{
{
Prefix
:
datastore
.
NewKey
(
"/quux"
),
Datastore
:
mapds
},
})
if
err
:=
mapds
.
Put
(
datastore
.
NewKey
(
"/thud"
),
[]
byte
(
"foobar"
));
err
!=
nil
{
t
.
Fatalf
(
"Put error: %v"
,
err
)
}
err
:=
m
.
Delete
(
datastore
.
NewKey
(
"/quux/thud"
))
if
err
!=
nil
{
t
.
Fatalf
(
"Delete error: %v"
,
err
)
}
// make sure it disappeared
found
,
err
:=
mapds
.
Has
(
datastore
.
NewKey
(
"/thud"
))
if
err
!=
nil
{
t
.
Fatalf
(
"Has error: %v"
,
err
)
}
if
g
,
e
:=
found
,
false
;
g
!=
e
{
t
.
Fatalf
(
"wrong value: %v != %v"
,
g
,
e
)
}
}
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