我可以使用下面的模拟服务进行模拟,但是当我尝试针对提供者验证模拟时,它会抛出错误。我怀疑是因为日期值。你能帮我看看可能是什么问题吗
模拟杰森文件:
@Mattthew - 感谢您的调查。我已经通过重新运行模拟清理了模拟。我没有模拟整个服务响应,而是只模拟了一项。
模拟代码:
'url = 'http://localhost:1234'
expected = {'class': 'HealthCheck'}
模拟 JSON:
'{
"consumer": {
"name": "consumer"
},
"provider": {
"name": "provider"
},
"interactions": [
{
"description": "a request for the health check",
"providerState": "the health of the system is OK",
"request": {
"method": "get",
"path": "/"
},
"response": {
"status": 200,
"headers": {
},
"body": {
"class": "HealthCheck"
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}'
真正的服务提供商回应:
'{
"class": [
"HealthCheck"
],
"properties": {
"timestamp": "2018-08-01T00:10:00+0000",
"systemName": "Test",
"buildInfo": {
"buildDate": "2018-07-27T07:38:19+0000",
"appVersion": "1111",
"revision": "2 ",
"branch": "develop"
},
"health": "OK",
"checks": []
},
"links": [
{
"rel": [
"self"
],
"href": " check"
}
]
}'
当我针对真正的提供者运行时出错: 1)验证消费者和提供者之间的协议鉴于系统的健康状况良好,使用 GET 进行检查的请求/返回具有匹配正文 失败/错误的响应:期望(response_body)。 to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8