Fix crc64 unit test
This commit is contained in:
6
db.go
6
db.go
@@ -1485,6 +1485,12 @@ func (db *DB) CRC64() (uint64, Pos, error) {
|
||||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
|
||||
if err := db.init(); err != nil {
|
||||
return 0, Pos{}, err
|
||||
} else if db.db == nil {
|
||||
return 0, Pos{}, os.ErrNotExist
|
||||
}
|
||||
|
||||
// Force a RESTART checkpoint to ensure the database is at the start of the WAL.
|
||||
if err := db.checkpoint(CheckpointModeRestart); err != nil {
|
||||
return 0, Pos{}, err
|
||||
|
||||
@@ -137,8 +137,8 @@ func TestDB_CRC64(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
} else if chksum1, _, err := db.CRC64(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if chksum0 != chksum1 {
|
||||
t.Fatal("expected equal checksum after WAL change")
|
||||
} else if chksum0 == chksum1 {
|
||||
t.Fatal("expected different checksum event after WAL change")
|
||||
}
|
||||
|
||||
// Checkpoint change into database. Checksum should change.
|
||||
|
||||
Reference in New Issue
Block a user