Implement Checksum()
This commit is contained in:
38
wal_test.go
38
wal_test.go
@@ -2,11 +2,30 @@ package litestream_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/benbjohnson/litestream"
|
||||
)
|
||||
|
||||
func TestWALFile_WriteHeader(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
f := MustOpenWALFile(t, "0000")
|
||||
defer MustCloseWALFile(t, f)
|
||||
|
||||
if err := f.WriteHeader(litestream.WALHeader{
|
||||
Magic: litestream.MagicLittleEndian,
|
||||
FileFormatVersion: 1001,
|
||||
PageSize: 4096,
|
||||
CheckpointSeqNo: 1003,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Fatal("TODO: Ensure header written correctly")
|
||||
})
|
||||
}
|
||||
|
||||
func TestWALHeader_MarshalTo(t *testing.T) {
|
||||
// Ensure the WAL header can be marshaled and unmarshaled correctly.
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
@@ -90,3 +109,22 @@ func TestWALFrameHeader_Unmarshal(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// MustOpenWALFile returns a new, open instance of WALFile written to a temp dir.
|
||||
func MustOpenWALFile(tb testing.TB, name string) *litestream.WALFile {
|
||||
tb.Helper()
|
||||
|
||||
f := litestream.NewWALFile(filepath.Join(tb.TempDir(), name))
|
||||
if err := f.Open(); err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// MustCloseWALFile closes an instance of WALFile.
|
||||
func MustCloseWALFile(tb testing.TB, f *litestream.WALFile) {
|
||||
tb.Helper()
|
||||
if err := f.Close(); err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user