我想为我的客户和 API 设置 Pact 合同测试。我的 API 无法在本地运行,因此我希望能够在部署到生产环境之前针对已部署的 API 暂存版本运行提供程序测试。
我在网上看到的大多数提供者测试示例都使用了 localhost。尝试针对我部署的 HTTPS 端点运行提供程序测试时,测试失败并显示read server hello A: unknown protocol. 是不支持 HTTPS 协议,还是我遗漏了什么?
func TestTenantProvider(t *testing.T) {
// Create Pact connecting to local Daemon
pact := &dsl.Pact{
Consumer: "TenantConsumer",
Provider: "TenantProvider",
}
// Verify the Provider with local Pact Files
pact.VerifyProvider(t, types.VerifyRequest{
ProviderBaseURL: "https://my-staging-endpoint.com",
PactURLs: []string{filepath.ToSlash(fmt.Sprintf("%s/tenantconsumer-tenantprovider.json", pactDir))},
})
}
使用pact-provider-verifier命令行工具可以正常工作。