Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasinsaurralde committed Jan 11, 2022
1 parent 5052bda commit 0f331b1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cmd_generic_test.go
Expand Up @@ -774,23 +774,21 @@ func TestCopy(t *testing.T) {
s.Set("key1", "value")
s.CheckGet(t, "key1", "value")
s.Copy("key1", "key2")
must0(t, c, "COPY", "key1", "key2")
// should return 1 after a successful copy operation:
must1(t, c, "COPY", "key1", "key2")
s.CheckGet(t, "key2", "value")

// should fail when trying to copy a nonexistent key:
// should return 0 when trying to copy a nonexistent key:
t.Run("nonexistent key", func(t *testing.T) {
mustDo(t, c,
"COPY", "nosuch", "to",
proto.Error("ERR no such key"),
)
must0(t, c, "COPY", "nosuch", "to")
})

// should return 1 when a key already exists:
// should return 0 when trying to overwrite an existing key:
t.Run("existing key", func(t *testing.T) {
s.Set("existingkey", "value")
s.Set("newkey", "newvalue")
must1(t, c, "COPY", "newkey", "existingkey")
// existing key value should be preserved:
must0(t, c, "COPY", "newkey", "existingkey")
// existing key value should remain unchanged:
s.CheckGet(t, "existingkey", "value")
})
}

0 comments on commit 0f331b1

Please sign in to comment.