-
| I feel like I'm missing something, and I don't see any examples of this in the PactSwiftExamples. I have a couple interactions that require several API calls to be mocked to test properly. For example: What happens when I do this, is that  I'm converting this from PactConsumerSwift, and this all worked fine there. Thanks! P.S. I know the obvious response is "separate your tests into single interactions", but I'm trying not to refactor production code at this point. | 
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 12 replies
-
| It relies on  These two show up in the Pact broker where having multiple of the same will end up with a conflicting and confusing list of interaction descriptions. | 
Beta Was this translation helpful? Give feedback.
-
| Yep I get that. Problem is, the function I need to call within the run needs to call multiple APIs. Is it a limitation of this library that only a single interaction can be mocked at a time (per run body)? Because that's going to be a showstopper for me.  | 
Beta Was this translation helpful? Give feedback.
-
| No. Same server, just different API paths. | 
Beta Was this translation helpful? Give feedback.
-
| I've quickly run this case and indeed  I'll have a look how to expose an interface that would allow setting multiple interactions to be tested with one  | 
Beta Was this translation helpful? Give feedback.
-
| Actually, might be easier than thought. Can you hold off on this particular case for a day or two so I can run a few more sanity checks on it and write some more unit tests for it? | 
Beta Was this translation helpful? Give feedback.
-
| @tsfischer in the mean time, you can try branch  How you'd need to do this now (reusing your initial code example):            let interactionLowercaseFoo = pactMockService
                .uponReceiving("A request for searching foo")
                .given("Computer is set up for foo")
                .withRequest(method: .POST, path: "myTestAPI1", headers: [ "Content-Type": "application/json" ], body:nil)
                .willRespondWith(<...my response for API 1...>)
            let interactionCapitalisedFoo = pactMockService
                .uponReceiving("A request for processing Foo")
                .given("Computer is set up for foo")
                .withRequest(method: .POST, path: "myTestAPI2", headers: [ "Content-Type": "application/json" ], body: nil)
                .willRespondWith(<...my response for API 2...>)
             
             // here's the puddin', the `verify: [Interaction]` argument. 👍 
             pactMockService.run(verify: [interactionLowercaseFoo, interactionCapitalisedFoo]) { url, done in
                // your network call
                // assertions and..
                done() 
             }Tested it on one of the demo projects and this is the result when one of the requests is invalid. EDIT: I reconsidered using  | 
Beta Was this translation helpful? Give feedback.
-
| This is now available from  | 
Beta Was this translation helpful? Give feedback.

@tsfischer in the mean time, you can try branch
feat/validate-interaction-set(https://github.com/surpher/PactSwift/tree/feat/validate-interaction-set).How you'd need to do this now (reusing your initial code example):