Fix canonical archive writes and retain scoped lifecycle evidence
This commit is contained in:
@@ -214,4 +214,26 @@ func TestCanonicalModelMigrationAndIncrementalLifecycle(t *testing.T) {
|
||||
if call("GET", base+"/model", nil, "", 200)["model"].(map[string]any)["complete"] != true {
|
||||
t.Fatal("initial read has no explicit coverage")
|
||||
}
|
||||
// An object created and removed inside one transaction still has a lifecycle fact.
|
||||
ghostID := modelTestID(4000)
|
||||
ghost := modelTestNode(ghostID, root)
|
||||
edit(1008, map[string]int64{root: 6}, modelChange{Kind: "element", ID: ghostID, Before: modelJSON(nil), After: modelJSON(ghost)}, modelChange{Kind: "element", ID: ghostID, Before: modelJSON(ghost), After: modelJSON(nil)})
|
||||
model = read()
|
||||
if model.Tombstones[ghostID] != 1 || model.Elements[ghostID] != nil {
|
||||
t.Fatal("in-batch create/delete lost its tombstone")
|
||||
}
|
||||
ghost["incarnation"] = float64(2)
|
||||
edit(1009, map[string]int64{root: 7}, modelChange{Kind: "element", ID: ghostID, Before: modelJSON(nil), After: modelJSON(ghost)})
|
||||
if modelInt(read().Elements[ghostID]["incarnation"]) != 2 {
|
||||
t.Fatal("restore after an in-batch delete did not preserve identity")
|
||||
}
|
||||
// Session changes cannot send an old account's queued request as a new account.
|
||||
request := httptest.NewRequest("GET", base+"/model", nil)
|
||||
request.Header.Set("Authorization", "Bearer "+token)
|
||||
request.Header.Set("X-Expected-Account", modelTestID(7777))
|
||||
writer := httptest.NewRecorder()
|
||||
mux.ServeHTTP(writer, request)
|
||||
if writer.Code != 409 {
|
||||
t.Fatal("expected-account barrier was ignored")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user