@@ -278,7 +278,7 @@ func (i *Interaction) addJSONConstraintsFromPact(path string, matchingRules map[
278278 case []interface {}:
279279 // Create constraints for each element in the array. This allows matching rules to override them.
280280 for j := range val {
281- i .addJSONConstraintsFromPact (fmt .Sprintf ("%v[%v ]" , path , j ), matchingRules , val [j ])
281+ i .addJSONConstraintsFromPact (fmt .Sprintf ("%s[%d ]" , path , j ), matchingRules , val [j ])
282282 }
283283 // Length constraint so that requests with additional elements at the end of the array will not match
284284 i .AddConstraint (interactionConstraint {
@@ -345,26 +345,26 @@ func (i *Interaction) EvaluateConstraints(request requestDocument, interactions
345345 i .mu .RLock ()
346346 defer i .mu .RUnlock ()
347347 for _ , constraint := range i .constraints {
348- values := constraint .Values
348+ expected := constraint .Values
349349 if constraint .Source != "" {
350350 var err error
351- values , err = i .loadValuesFromSource (constraint , interactions )
351+ expected , err = i .loadValuesFromSource (constraint , interactions )
352352 if err != nil {
353353 violations = append (violations , err .Error ())
354354 result = false
355355 continue
356356 }
357357 }
358358
359- val , err := jsonpath .Get (request .encodeValues (constraint .Path ), map [string ]interface {}(request ))
359+ actual , err := jsonpath .Get (request .encodeValues (constraint .Path ), map [string ]interface {}(request ))
360360 if err != nil {
361361 violations = append (violations ,
362362 fmt .Sprintf ("constraint path %q cannot be resolved within request: %q" , constraint .Path , err ))
363363 result = false
364364 continue
365365 }
366366
367- if err := constraint .Check ( values , val ); err != nil {
367+ if err := constraint .check ( expected , actual ); err != nil {
368368 violations = append (violations , err .Error ())
369369 result = false
370370 }
0 commit comments