Pact:使用相同的端点编写不同的交互
Pact: Write different interactions with same endpoint
我有一种情况,我用同一个端点编写了 2 个交互。
即使我在 with_request 选项中传递了不同的查询,我也遇到了以下错误 -
Error: Multiple interaction found for GET /a1/configurations?includeDeleted=true&
第一次互动:
withRequest: {
method: "GET",
path: `/a1/configurations`,
query: {
includeDeleted: "false",
}
}
第二次互动:
withRequest: {
method: "GET",
path: `/a1/configurations`,
query: {
includeDeleted: "true",
}
}
任何人都可以帮助我找到满足此要求的方法吗?
谢谢!!
我怀疑您的两个请求具有相同的名称,由 uponReceiving
设置。
错误消息表明您的代码类似于:
uponReceiving: 'GET /a1/configurations?includeDeleted=true&'
withRequest: { ... }
uponReceiving: 'GET /a1/configurations?includeDeleted=true&'
withRequest: { ... }
如果 withRequest
详细信息不同,uponReceiving
的值必须是唯一的。
为了最佳实践,我建议使用人类可读的字符串(这有助于报告):
uponReceiving: 'a request for configurations that are not deleted',
withRequest: { method: "GET", path: /a1/configurations, query: { includeDeleted: "false", } }
及以后:
uponReceiving: 'a request for all configurations',
withRequest: { method: "GET", path: /a1/configurations, query: { includeDeleted: "true", } }
我有一种情况,我用同一个端点编写了 2 个交互。 即使我在 with_request 选项中传递了不同的查询,我也遇到了以下错误 -
Error: Multiple interaction found for GET /a1/configurations?includeDeleted=true&
第一次互动:
withRequest: {
method: "GET",
path: `/a1/configurations`,
query: {
includeDeleted: "false",
}
}
第二次互动:
withRequest: {
method: "GET",
path: `/a1/configurations`,
query: {
includeDeleted: "true",
}
}
任何人都可以帮助我找到满足此要求的方法吗?
谢谢!!
我怀疑您的两个请求具有相同的名称,由 uponReceiving
设置。
错误消息表明您的代码类似于:
uponReceiving: 'GET /a1/configurations?includeDeleted=true&'
withRequest: { ... }
uponReceiving: 'GET /a1/configurations?includeDeleted=true&'
withRequest: { ... }
如果 withRequest
详细信息不同,uponReceiving
的值必须是唯一的。
为了最佳实践,我建议使用人类可读的字符串(这有助于报告):
uponReceiving: 'a request for configurations that are not deleted',
withRequest: { method: "GET", path: /a1/configurations, query: { includeDeleted: "false", } }
及以后:
uponReceiving: 'a request for all configurations',
withRequest: { method: "GET", path: /a1/configurations, query: { includeDeleted: "true", } }