pact

Micronaut set up EmbeddedServer for Pact test

☆樱花仙子☆ 提交于 2019-12-13 02:56:53
问题 I have this SpringBoot and Pact test example from Writing Contract Tests with Pact in Spring Boot @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = "user-service.base-url:http://localhost:8080", classes = UserServiceClient.class) public class UserServiceContractTest { @Rule public PactProviderRuleMk2 provider = new PactProviderRuleMk2("user-service", null, 8080, this); @Autowired private UserServiceClient userServiceClient; @Pact

pact: validate that an array contains a matching hash

ε祈祈猫儿з 提交于 2019-12-11 15:46:10
问题 I have a service that returns an array of hashes, the order of which is non-deterministic. I need to validate that there exists one hash that has a certain key/value, and that hash is populated with data, but the rest of the hashes I don't care about their data. For example, if the service returns this: [ { "key":"meaningless1", "data": { } }, { "key":"meaningless2", "data": { "some": "data", "goes": ["here"] } }, { "key":"meaningful", "data": { "regex": "value", "integer": 1, "boolean": true

Pact Groovy Mock with Array in Body

余生颓废 提交于 2019-12-11 07:25:49
问题 I would like to model my much such that its body consists of an array of n elements. The below code only creates one element in the array, when it should produce three. withBody(eachLike(3, { id identifier state("COMPLETED") type regexp("(A|B)", "A") })) Oddly enough, if I name the name collection, it actually generates three objects: withBody { namedObject eachLike(3, { id identifier }) } Where do I go wrong? Is this a bug? 来源: https://stackoverflow.com/questions/46523414/pact-groovy-mock

Pact. How to test a REST GET with automatically generated ID in the URL

左心房为你撑大大i 提交于 2019-12-11 05:56:05
问题 I want to test a REST service that returns the detail of a given entity identified by an UUID, i.e. my consumer pact has an interaction requesting a GET like this: /cities/123e4567-e89b-12d3-a456-426655440000 So I need this specific record to exist in the Database for the pact verifier to find it. In other projects I've achieved this executing an SQL INSERT in the state setup, but in this case I'd prefer to use the microservice's JPA utilities for accessing to the DB, because the data model

How do I verify pacts against an API that requires an auth token?

旧巷老猫 提交于 2019-12-02 06:29:51
问题 I'm using the Pact gem (and loving it!) for my contract test suite. The API service I'm testing requires an authorization token for all requests. I know how to generate an API token for my user, but I don't know where to place the token in the Pact workflow. I searched the Pact documentation and repo for examples but didn't have any luck. I tried sending a POST in the consumer specs to generate a token, but the Pact mock server doesn't know what to do with the request and errors out (as I

How do I verify pacts against an API that requires an auth token?

大城市里の小女人 提交于 2019-12-02 00:14:27
I'm using the Pact gem (and loving it!) for my contract test suite. The API service I'm testing requires an authorization token for all requests. I know how to generate an API token for my user, but I don't know where to place the token in the Pact workflow. I searched the Pact documentation and repo for examples but didn't have any luck. I tried sending a POST in the consumer specs to generate a token, but the Pact mock server doesn't know what to do with the request and errors out (as I would expect). I found this example and it seems promising, particularly the ability to assign predefined