Initial commit: archer, a Go-native MySQL/MariaDB table archiver
Renamed from arcdb: module path, cmd/archer, internal/archererr, docs, build scripts and ARCHER_* environment variables. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
bc4a6b504f
99 files changed
+12752
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package checkpoint
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"archer/internal/row"
|
||||
)
|
||||
|
||||
func TestSaveLoadRoundTrip(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
st := &State{
|
||||
RunID: "run-1",
|
||||
ConfigHash: "abc",
|
||||
ShardBy: "date",
|
||||
Cursor: Cursor{Phase: "value", Key: row.KeyOf("2025-01-01 00:00:00", "42")},
|
||||
LastBucket: "2025-01-01",
|
||||
RowsDone: 99,
|
||||
}
|
||||
if err := Save(dir, st); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(Path(dir) + ".tmp"); !os.IsNotExist(err) {
|
||||
t.Fatal("temp state file should not remain")
|
||||
}
|
||||
got, err := Load(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got == nil || got.RunID != "run-1" || got.RowsDone != 99 || got.LastBucket != "2025-01-01" {
|
||||
t.Fatalf("got %+v", got)
|
||||
}
|
||||
if got.Cursor.Phase != "value" || len(got.Cursor.Key) != 2 || got.Cursor.Key[1].Val != "42" {
|
||||
t.Fatalf("cursor %+v", got.Cursor)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadMissing(t *testing.T) {
|
||||
st, err := Load(t.TempDir())
|
||||
if err != nil || st != nil {
|
||||
t.Fatalf("got %v %v", st, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user