Bind canonical AI admission to the project version vector
This commit is contained in:
@@ -56,3 +56,42 @@ func TestCanonicalAIProjectionDoesNotExecuteFutureConnections(t *testing.T) {
|
||||
t.Fatal("future connection was executed or removed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCanonicalAIAdmissionVersions(t *testing.T) {
|
||||
model := modelTestDocument()
|
||||
model.Canvases[modelChildID] = modelCanvas{ID: modelChildID}
|
||||
model.Versions[modelChildID] = 3
|
||||
// Include an archived version: it must not become an executable read dependency.
|
||||
model.Versions["archived"] = 8
|
||||
valid := map[string]int64{}
|
||||
for id := range model.Canvases {
|
||||
valid[id] = model.Versions[id]
|
||||
}
|
||||
if code := validateCanvasAIVersions(model, modelRootID, valid[modelRootID], valid); code != "" {
|
||||
t.Fatal(code)
|
||||
}
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
versions map[string]int64
|
||||
header int64
|
||||
want string
|
||||
}{
|
||||
{"missing", nil, 1, "invalid_ai_versions"},
|
||||
{"changed-header", valid, 99, "invalid_ai_versions"},
|
||||
{"incomplete", map[string]int64{modelRootID: 1}, 1, "invalid_ai_versions"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if got := validateCanvasAIVersions(model, modelRootID, test.header, test.versions); got != test.want {
|
||||
t.Fatalf("got %q want %q", got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
stale := map[string]int64{}
|
||||
for id, version := range valid {
|
||||
stale[id] = version
|
||||
}
|
||||
stale[modelChildID]++
|
||||
if code := validateCanvasAIVersions(model, modelRootID, valid[modelRootID], stale); code != "version_conflict" {
|
||||
t.Fatal(code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user