Skip to content

Commit c21782e

Browse files
author
Dan Laine
authored
merkledb -- db_test.go cleanup (#1954)
1 parent 0cf3d29 commit c21782e

File tree

3 files changed

+316
-216
lines changed

3 files changed

+316
-216
lines changed

database/test_database.go

+17
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
// Tests is a list of all database tests
2525
var Tests = []func(t *testing.T, db Database){
2626
TestSimpleKeyValue,
27+
TestOverwriteKeyValue,
2728
TestEmptyKey,
2829
TestKeyEmptyValue,
2930
TestSimpleKeyValueClosed,
@@ -103,6 +104,22 @@ func TestSimpleKeyValue(t *testing.T, db Database) {
103104
require.NoError(db.Delete(key))
104105
}
105106

107+
func TestOverwriteKeyValue(t *testing.T, db Database) {
108+
require := require.New(t)
109+
110+
key := []byte("hello")
111+
value1 := []byte("world1")
112+
value2 := []byte("world2")
113+
114+
require.NoError(db.Put(key, value1))
115+
116+
require.NoError(db.Put(key, value2))
117+
118+
gotValue, err := db.Get(key)
119+
require.NoError(err)
120+
require.Equal(value2, gotValue)
121+
}
122+
106123
func TestKeyEmptyValue(t *testing.T, db Database) {
107124
require := require.New(t)
108125

0 commit comments

Comments
 (0)