Skip to content

merkledb -- db_test.go cleanup #1954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 7, 2023
17 changes: 17 additions & 0 deletions database/test_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
// Tests is a list of all database tests
var Tests = []func(t *testing.T, db Database){
TestSimpleKeyValue,
TestOverwriteKeyValue,
TestEmptyKey,
TestKeyEmptyValue,
TestSimpleKeyValueClosed,
Expand Down Expand Up @@ -103,6 +104,22 @@ func TestSimpleKeyValue(t *testing.T, db Database) {
require.NoError(db.Delete(key))
}

func TestOverwriteKeyValue(t *testing.T, db Database) {
require := require.New(t)

key := []byte("hello")
value1 := []byte("world1")
value2 := []byte("world2")

require.NoError(db.Put(key, value1))

require.NoError(db.Put(key, value2))

gotValue, err := db.Get(key)
require.NoError(err)
require.Equal(value2, gotValue)
}

func TestKeyEmptyValue(t *testing.T, db Database) {
require := require.New(t)

Expand Down
Loading