feat: ship loose-offline dbsync (validate, agent push, LWW audit)
Add UUID/FK channel checks, agent whitelist/push APIs, bindings, super-admin LWW audit with rollback, reconcile rate limits, and sync docs. Default customers stay opt-in; company conflict UI is removed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
35
platform/internal/dbsync/binding_test.go
Normal file
35
platform/internal/dbsync/binding_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package dbsync
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnsureBindingUpsert(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
st, err := NewFileStore(filepath.Join(dir, "dbsync"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b, err := st.EnsureBinding(Binding{
|
||||
TenantID: 1,
|
||||
LocalDatabaseID: "local-a",
|
||||
OnlineDBID: "online-1",
|
||||
ChannelID: "ch1",
|
||||
})
|
||||
if err != nil || b.ID == "" {
|
||||
t.Fatalf("ensure: %+v err=%v", b, err)
|
||||
}
|
||||
b2, err := st.EnsureBinding(Binding{
|
||||
TenantID: 1,
|
||||
LocalDatabaseID: "local-a",
|
||||
OnlineDBID: "online-2",
|
||||
})
|
||||
if err != nil || b2.OnlineDBID != "online-2" || b2.ID != b.ID {
|
||||
t.Fatalf("upsert: %+v err=%v", b2, err)
|
||||
}
|
||||
list, err := st.ListBindings(1, "local-a")
|
||||
if err != nil || len(list) != 1 {
|
||||
t.Fatalf("list=%d err=%v", len(list), err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user