Embed protocol fixture for isolated integration test binaries
This commit is contained in:
@@ -2,9 +2,9 @@ package platform
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -12,6 +12,11 @@ const modelRootID = "10000000-0000-4000-8000-000000000001"
|
||||
const modelChildID = "10000000-0000-4000-8000-000000000002"
|
||||
const modelLegacyFrame = `{"id":"f","type":"frame","position":{"x":100,"y":200},"width":640,"height":400,"data":{"kind":"frame","title":"Partition","text":"","labelMode":"fixed"}}`
|
||||
|
||||
// The schema runner mounts only the test binary, not the source tree.
|
||||
//
|
||||
//go:embed testdata/foundry-model-operation-v2.json
|
||||
var canonicalFrontendFixture []byte
|
||||
|
||||
func modelJSON(value any) json.RawMessage { raw, _ := json.Marshal(value); return raw }
|
||||
func modelTestID(n int) string { return fmt.Sprintf("90000000-0000-4000-8000-%012d", n) }
|
||||
func modelTestAllocator() func() string {
|
||||
@@ -153,14 +158,10 @@ func TestCanonicalValidationRejectsPartialChangesAndWrongEdgeOwner(t *testing.T)
|
||||
}
|
||||
|
||||
func TestCanonicalFrontendProtocolFixture(t *testing.T) {
|
||||
raw, err := os.ReadFile("testdata/foundry-model-operation-v2.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var input modelBatch
|
||||
decoder := json.NewDecoder(bytes.NewReader(raw))
|
||||
decoder := json.NewDecoder(bytes.NewReader(canonicalFrontendFixture))
|
||||
decoder.DisallowUnknownFields()
|
||||
if err = decoder.Decode(&input); err != nil {
|
||||
if err := decoder.Decode(&input); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if input.ProtocolVersion != canvasModelProtocol || !uuidSlugPattern.MatchString(input.RequestID) || input.Expected[modelRootID] != 3 {
|
||||
|
||||
Reference in New Issue
Block a user