@@ -650,7 +650,12 @@ default:
650650 r := strings .NewReplacer (`"` , "" , `\` , "" )
651651 rkey := r .Replace (key )
652652 output += ` if ` + nilGuard + ` { t.Error("Expected [` + rkey + `] to not be nil") }
653- actual = ` + escape (subject ) + `.(encjson.Number).String()
653+ actual = ` + escape (subject ) + `
654+ if intValue, ok := actual.(int); ok {
655+ actual = fmt.Sprint(intValue)
656+ } else {
657+ actual = actual.(encjson.Number).String()
658+ }
654659 expected = ` + expected + `
655660 // TEMP: Hack to prevent 1.0 != 1 errors
656661 if strings.HasSuffix(actual.(string), ".0") {
@@ -676,11 +681,14 @@ default:
676681
677682 // --------------------------------------------------------------------------------
678683 case map [interface {}]interface {}, map [string ]interface {}:
684+ // We cannot reliably serialize to json and compare the json outputs: YAML responses are parsed as
685+ // a map[interface{}]interface{} that encoding/json fails to marshall
686+ // See https://play.golang.org/p/jhcXwg5dIrn
679687 expectedPayload := fmt .Sprintf ("%#v" , val )
680688 expectedPayload = strings .ReplaceAll (expectedPayload , "map[interface {}]interface {}" , "map[string]interface {}" )
681- output = ` actual, _ = encjson.Marshal( ` + escape (subject ) + `)
682- expected, _ = encjson.Marshal( ` + expectedPayload + `)
683- if fmt.Sprintf("%s", actual) != fmt.Sprintf("%s", expected) {` + "\n "
689+ output = ` actual = fmt.Sprintf("%v", ` + escape (subject ) + `)
690+ expected = fmt.Sprintf("%v", ` + expectedPayload + `)
691+ if actual != expected {` + "\n "
684692
685693 // --------------------------------------------------------------------------------
686694 case []interface {}:
0 commit comments