@@ -232,7 +232,7 @@ func (m *Message) WithContents(part interactionPart, contentType string, body []
232232 defer free (cHeader )
233233
234234 cBody := C .CString (string (body ))
235- defer free (cBody )
235+ defer free (cBody )
236236
237237 res := C .pactffi_with_body (m .handle , C .int (part ), cHeader , cBody )
238238 log .Println ("[DEBUG] response from pactffi_interaction_contents" , (bool (res )))
@@ -264,7 +264,7 @@ func (m *MessageServer) UsingPlugin(pluginName string, pluginVersion string) err
264264 return ErrHandleNotFound
265265 default :
266266 if res != 0 {
267- return fmt .Errorf ("an unknown error (code: %v) occurred when adding a plugin for the test. Received error code: " , res )
267+ return fmt .Errorf ("an unknown error (code: %v) occurred when adding a plugin for the test. Received error code" , res )
268268 }
269269 }
270270
@@ -302,7 +302,7 @@ func (m *Message) WithPluginInteractionContents(part interactionPart, contentTyp
302302 return ErrPluginSpecificError
303303 default :
304304 if res != 0 {
305- return fmt .Errorf ("an unknown error (code: %v) occurred when adding a plugin for the test. Received error code: " , res )
305+ return fmt .Errorf ("an unknown error (code: %v) occurred when adding a plugin for the test. Received error code" , res )
306306 }
307307 }
308308
@@ -543,10 +543,7 @@ func (m *MessageServer) WritePactFile(dir string, overwrite bool) error {
543543 cDir := C .CString (dir )
544544 defer free (cDir )
545545
546- overwritePact := false
547- if overwrite {
548- overwritePact = true
549- }
546+ overwritePact := overwrite
550547
551548 res := int (C .pactffi_write_message_pact_file (m .messagePact .handle , cDir , C .bool (overwritePact )))
552549
@@ -572,10 +569,7 @@ func (m *MessageServer) WritePactFileForServer(port int, dir string, overwrite b
572569 cDir := C .CString (dir )
573570 defer free (cDir )
574571
575- overwritePact := false
576- if overwrite {
577- overwritePact = true
578- }
572+ overwritePact := overwrite
579573
580574 res := int (C .pactffi_write_pact_file (C .int (port ), cDir , C .bool (overwritePact )))
581575
@@ -596,3 +590,19 @@ func (m *MessageServer) WritePactFileForServer(port int, dir string, overwrite b
596590 return fmt .Errorf ("an unknown error ocurred when writing to pact file" )
597591 }
598592}
593+
594+ // WithReference records an external reference (e.g. a ticket or pull request)
595+ // against the interaction. References are stored under comments.references[group][name]
596+ // in the Pact file. This is a V4-only feature.
597+ func (m * Message ) WithReference (group , name , value string ) * Message {
598+ cGroup := C .CString (group )
599+ defer free (cGroup )
600+ cName := C .CString (name )
601+ defer free (cName )
602+ cValue := C .CString (value )
603+ defer free (cValue )
604+
605+ C .pactffi_add_interaction_reference (m .handle , cGroup , cName , cValue )
606+
607+ return m
608+ }
0 commit comments