Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
qichengzx committed Mar 1, 2023
1 parent 7f58d3d commit d337442
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions index_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package bitcask

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
)

var (
key = "keyname"
idx = newIndex()
ety = newEntry(1, uint32(len(key)), 100, 20, uint64(time.Now().Unix()))
)

func TestIndexPut(t *testing.T) {
idx.put(key, ety)
}

func TestIndexGet(t *testing.T) {
e, err := idx.get([]byte(key))
if err != nil {
t.Fatalf("key %s not found", key)
}
assert.Equal(t, e, ety)
}

func TestIndexNotFound(t *testing.T) {
_, err := idx.get([]byte("notexists"))
assert.Equal(t, err, ErrKeyNotFound)
}

0 comments on commit d337442

Please sign in to comment.