我想通过使用 Stripe CLI 触发一些特定请求来测试我的 API 行为.
例如:
strip 触发器 customer.subscription.deleted # 这里有一些固定装置
有一个 fixtures 命令记录为一个功能,但我不知道如何使用它。文档说:
The fixtures command lets you run a json file as a series of API requests. This can be useful for things like filling data, executing specific flows, or testing API behavior.
https://github.com/stripe/stripe-cli/wiki/fixtures-command
如何将夹具加载到 CLI 中?
最佳答案
第一步是创建一个包含灯具的 JSON 文件。您链接到的文档提供了一个这样的示例,但如果您:
然后您可以使用 stripe fixtures name_of_your_fixture_file.json
执行夹具
您可以在 trigger documentation 中查找可用的触发器.请记住,固定装置只会发出一系列 API 请求,fixtures
数组中的每个对象代表一个 API 调用,因此您可以执行 API docs 中指定的任何操作。 .
https://stackoverflow.com/questions/59745126/