gpt4 book ai didi

javascript - Pact:使用相同的端点编写不同的交互

转载 作者:行者123 更新时间:2023-11-29 20:46:23 27 4
gpt4 key购买 nike

我有一种情况,我用同一个端点编写了 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", } }

关于javascript - Pact:使用相同的端点编写不同的交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54389632/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com