Skip to content

Commit

Permalink
store tests: add test for IsKeyDir
Browse files Browse the repository at this point in the history
Before adding IsKeyDir we should add tests.
IsKeyDir is necessary to address etcd-io#518 on github
  • Loading branch information
iankronquist committed Jan 25, 2015
1 parent 93e4880 commit 056fae8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ func TestStoreGetSorted(t *testing.T) {
}
}

func Test(t *testing.T) {
s := newStore()
// Set /foo to be a directory
s.Set("/foo", true, "", Permanent)
val := s.IsKeyDir("/foo")
assert.True(t, val, "")
// Set /foo/bar="baz"
s.Set("/foo/bar", false, "baz", Permanent)
val = s.IsKeyDir("/foo/bar")
assert.False(t, val, "")
// Assert that an invalid key is false
val = s.IsKeyDir("/foo/invalid")
assert.False(t, val, "")
}

func TestSet(t *testing.T) {
s := newStore()

Expand Down

0 comments on commit 056fae8

Please sign in to comment.