Skip to content

Commit

Permalink
fix(server): fix wrong options for testing (#552)
Browse files Browse the repository at this point in the history
## Motivation

Using in-memory DB will not help validate re-open related logic.


## Modification

- Using temp dir for re-open related testing.
  • Loading branch information
mattisonchao authored Oct 17, 2024
1 parent 6778f7f commit 5ecb61e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions server/kv/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ package kv

import (
"fmt"
"github.com/google/uuid"
"os"
"path"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -445,7 +448,11 @@ func TestDB_ReadCommitOffset(t *testing.T) {
}

func TestDb_UpdateTerm(t *testing.T) {
factory, err := NewPebbleKVFactory(testKVOptions)
factory, err := NewPebbleKVFactory(&FactoryOptions{
InMemory: false,
CacheSizeMB: 1,
DataDir: path.Join(os.TempDir(), uuid.New().String()),
})
assert.NoError(t, err)
db, err := NewDB(common.DefaultNamespace, 1, factory, 0, common.SystemClock)
assert.NoError(t, err)
Expand All @@ -471,15 +478,19 @@ func TestDb_UpdateTerm(t *testing.T) {

term, _, err = db.ReadTerm()
assert.NoError(t, err)
assert.Equal(t, wal.InvalidOffset, term)
assert.EqualValues(t, 1, term)

assert.NoError(t, factory.Close())
}

func TestDB_Delete(t *testing.T) {
offset := int64(13)

factory, err := NewPebbleKVFactory(testKVOptions)
factory, err := NewPebbleKVFactory(&FactoryOptions{
InMemory: false,
CacheSizeMB: 1,
DataDir: path.Join(os.TempDir(), uuid.New().String()),
})
assert.NoError(t, err)
db, err := NewDB(common.DefaultNamespace, 1, factory, 0, common.SystemClock)
assert.NoError(t, err)
Expand Down

0 comments on commit 5ecb61e

Please sign in to comment.