feat: initialize project structure and error types
- go.mod with github.com/dailz/go-kv, Go 1.26.3, testify - config/config.go with WalConfig, Validate() with checked arithmetic - errors.go with sentinel errors (ErrCommitUnknown, ErrWriteStopped, etc.) - wal/constants.go with all WAL format constants and enums - wal/header.go with WAL File Header encode/decode (CRC32 IEEE) - wal/record.go with Physical Record codec, block boundary, SplitIntoRecords - wal/entry.go with WAL Entry codec (varint keys/values, OpType, ValueKind) - wal/sequence.go with SequenceManager (atomic, CAS, overflow-safe) - manifest/manifest.go with MANIFEST stub (Load/Save atomic) - manifest/current.go with CURRENT file (WriteCurrent/ReadCurrent) - Comprehensive tests for all modules - .golangci.yml configuration
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package manifest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestManifestRoundtrip(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
err := Save(dir, 42)
|
||||
require.NoError(t, err)
|
||||
|
||||
m, err := Load(dir)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, uint64(42), m.RecoverySegmentID)
|
||||
}
|
||||
|
||||
func TestManifestMissing(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
m, err := Load(dir)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, uint64(0), m.RecoverySegmentID)
|
||||
}
|
||||
|
||||
func TestCurrentRoundtrip(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
err := WriteCurrent(dir, 5)
|
||||
require.NoError(t, err)
|
||||
|
||||
segmentID, ok := ReadCurrent(dir)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, uint64(5), segmentID)
|
||||
}
|
||||
|
||||
func TestCurrentMissing(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
_, ok := ReadCurrent(dir)
|
||||
assert.False(t, ok)
|
||||
}
|
||||
Reference in New Issue
Block a user