Documentation
¶
Overview ¶
Package conflicttest provides conflict scenario runners built on pkg/sync and pkg/conflict for tests.
Scenario wires two synctest.Device nodes, a synctest.MemHub with stale-base detection enabled, and conflict.NewDefaultEngine().
Typical flows:
- Evaluate — run Detect and Merge for a local/base/current triple without sync I/O
- RunStaleBaseConflict — seed a hub-side current version and assert AckConflicted + conflict records
- RunTwoNodeStaleBaseConflict — push node B first, then assert node A conflicts on stale base
- RunAutoMergeResolution — process a sync.conflict_processing job, resubmit the merged update, and assert the canonical event was created
DefaultConcurrentPatientEdits returns a standard non-overlapping patient edit triple (telecom vs address) suitable for auto-merge scenarios.
EnvelopeFromFields and LocalUpdate are low-level helpers for building conflict inputs without importing sync event types into unrelated tests.
Index ¶
- func EnvelopeFromFields(resourceType, id, version string, fields map[string]any) (*types.ResourceEnvelope, error)
- func LocalUpdate(resourceType, id, baseVersion, localVersion string, ...) conflict.LocalEvent
- func StoreBackend(d *synctest.Device) *storetest.Backend
- type EditNodes
- type Result
- type Scenario
- func (s *Scenario) Evaluate(local conflict.LocalEvent, base, current *types.ResourceEnvelope) Result
- func (s *Scenario) RunAutoMergeResolution(ctx context.Context, edits EditNodes) (*Result, error)
- func (s *Scenario) RunStaleBaseConflict(ctx context.Context, edits EditNodes) (*Result, error)
- func (s *Scenario) RunTwoNodeStaleBaseConflict(ctx context.Context, edits EditNodes) (*Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvelopeFromFields ¶
func EnvelopeFromFields(resourceType, id, version string, fields map[string]any) (*types.ResourceEnvelope, error)
EnvelopeFromFields builds a normalized envelope from a field map.
func LocalUpdate ¶
func LocalUpdate(resourceType, id, baseVersion, localVersion string, after *types.ResourceEnvelope) conflict.LocalEvent
LocalUpdate builds a conflict.LocalEvent for evaluation.
Types ¶
type EditNodes ¶
type EditNodes struct {
Base *types.ResourceEnvelope
LocalA *types.ResourceEnvelope
LocalB *types.ResourceEnvelope
Cloud *types.ResourceEnvelope
}
EditNodes holds the two concurrent edit envelopes for a conflict scenario.
func DefaultConcurrentPatientEdits ¶
DefaultConcurrentPatientEdits returns a standard non-overlapping edit triple.
type Result ¶
type Result struct {
DetectResult conflict.Result
MergeResult conflict.MergeResult
PushSummary *hasync.PushResultSummary
Conflicts []store.ConflictRecord
CanonicalEvents []hasync.CanonicalEvent
ResolutionPush []hasync.PushResult
CanonicalCount int
AuditRecords []store.AuditRecord
AutoMerged bool
NeedsReview bool
}
Result captures conflict evaluation and sync artifacts.
type Scenario ¶
type Scenario struct {
Hub *synctest.MemHub
DeviceA *synctest.Device
DeviceB *synctest.Device
Engine *conflict.Engine
Clock hasync.Clock
TenantID string
}
Scenario runs conflict detection and optional resolution through sync + conflict.
func NewScenario ¶
NewScenario creates a conflict test scenario with stale-base detection enabled.
func (*Scenario) Evaluate ¶
func (s *Scenario) Evaluate(local conflict.LocalEvent, base, current *types.ResourceEnvelope) Result
Evaluate runs conflict.Detect and conflict.Merge for a local edit triple.
func (*Scenario) RunAutoMergeResolution ¶
RunAutoMergeResolution processes a conflict job when the engine auto-merges.
func (*Scenario) RunStaleBaseConflict ¶
RunStaleBaseConflict seeds node A's edit against a newer hub version and pushes.