@@ -111,6 +111,44 @@ func TestRunEditorBundleLoadsPluginContractDescriptorSetReference(t *testing.T)
111111 }
112112}
113113
114+ func TestRunEditorBundleLoadsMessageContractDescriptor (t * testing.T ) {
115+ dir := t .TempDir ()
116+ outPath := filepath .Join (dir , "editor-bundle.json" )
117+
118+ if err := runEditorBundle ([]string {"--registry=false" , "--plugin-dir" , "testdata/plugins/message-contract" , "--output" , outPath }); err != nil {
119+ t .Fatalf ("editor-bundle failed: %v" , err )
120+ }
121+
122+ data , err := os .ReadFile (outPath )
123+ if err != nil {
124+ t .Fatalf ("read output: %v" , err )
125+ }
126+ var bundle struct {
127+ Contracts map [string ]struct {
128+ DescriptorSetRef string `json:"descriptorSetRef"`
129+ ProtoPackage string `json:"protoPackage"`
130+ MessageNames []string `json:"messageNames"`
131+ ProtocolVersion string `json:"protocolVersion"`
132+ } `json:"contracts"`
133+ }
134+ if err := json .Unmarshal (data , & bundle ); err != nil {
135+ t .Fatalf ("bundle is not valid JSON: %v" , err )
136+ }
137+ contract := bundle .Contracts ["message:compute.network_audit_evidence.v1" ]
138+ if contract .DescriptorSetRef != "descriptors/message.pb" {
139+ t .Fatalf ("descriptorSetRef = %q" , contract .DescriptorSetRef )
140+ }
141+ if contract .ProtoPackage != "workflow_plugin_compute_core.protocol.v1" {
142+ t .Fatalf ("protoPackage = %q" , contract .ProtoPackage )
143+ }
144+ if len (contract .MessageNames ) != 2 || contract .MessageNames [0 ] != "NetworkAuditRecord" {
145+ t .Fatalf ("messageNames = %v" , contract .MessageNames )
146+ }
147+ if contract .ProtocolVersion != "compute.v1alpha1" {
148+ t .Fatalf ("protocolVersion = %q" , contract .ProtocolVersion )
149+ }
150+ }
151+
114152func TestRunEditorBundleRejectsMalformedPluginContractDescriptors (t * testing.T ) {
115153 dir := t .TempDir ()
116154 pluginDir := filepath .Join (dir , "workflow-plugin-bad-contracts" )
@@ -298,6 +336,26 @@ func TestRunEditorBundlePreservesPerContractDescriptorSetReferences(t *testing.T
298336 "input": "workflow.two.Input",
299337 "output": "workflow.two.Output",
300338 "descriptorSetRef": "proto/two.pb"
339+ },
340+ {
341+ "kind": "message",
342+ "contractType": "message.one",
343+ "mode": "strict",
344+ "protoPackage": "workflow.one",
345+ "messageNames": ["Event"],
346+ "schemaDigest": "sha256:one",
347+ "protocolVersion": "v1",
348+ "descriptorSetRef": "proto/message-one.pb"
349+ },
350+ {
351+ "kind": "message",
352+ "contractType": "message.two",
353+ "mode": "strict",
354+ "protoPackage": "workflow.two",
355+ "messageNames": ["Event"],
356+ "schemaDigest": "sha256:two",
357+ "protocolVersion": "v1",
358+ "descriptorSetRef": "proto/message-two.pb"
301359 }
302360 ]
303361}` ), 0644 ); err != nil {
@@ -339,6 +397,18 @@ func TestRunEditorBundlePreservesPerContractDescriptorSetReferences(t *testing.T
339397 if got := bundle .Messages ["workflow.two.Input" ].DescriptorSetRef ; got != "proto/two.pb" {
340398 t .Fatalf ("workflow.two.Input descriptorSetRef = %q" , got )
341399 }
400+ if got := bundle .Contracts ["message:message.one" ].DescriptorSetRef ; got != "proto/message-one.pb" {
401+ t .Fatalf ("message.one descriptorSetRef = %q" , got )
402+ }
403+ if got := bundle .Contracts ["message:message.two" ].DescriptorSetRef ; got != "proto/message-two.pb" {
404+ t .Fatalf ("message.two descriptorSetRef = %q" , got )
405+ }
406+ if got := bundle .Messages ["workflow.one.Event" ].DescriptorSetRef ; got != "proto/message-one.pb" {
407+ t .Fatalf ("workflow.one.Event descriptorSetRef = %q" , got )
408+ }
409+ if got := bundle .Messages ["workflow.two.Event" ].DescriptorSetRef ; got != "proto/message-two.pb" {
410+ t .Fatalf ("workflow.two.Event descriptorSetRef = %q" , got )
411+ }
342412 if bundle .DescriptorSets ["proto/one.pb" ].ExternalRef != "proto/one.pb" {
343413 t .Fatalf ("descriptor set one reference missing: %+v" , bundle .DescriptorSets )
344414 }
0 commit comments