DiUS / pact-consumer-swift

A Swift / ObjeciveC DSL for creating pacts.
MIT License
98 stars 43 forks source link

Pact tests not working with OpenCombine and Combine code #104

Closed ManaliM27 closed 3 years ago

ManaliM27 commented 3 years ago

Hi, The Pact tests are not working with Combine and OpenCombine code I have written code to download the data using OpenCombine (Tried the same using Combine). But the pact tests are not working with that code. I am getting Timeout error. On executing the Pact tests, code control never reaches the tryMap block (Code Below)

Error : "failed - test did not complete within 30.0 second timeout" Error persists even after increasing the timeout interval

Code :

 var dataPublisher: AnyPublisher<URLSession.DataTaskPublisher.Output, URLSession.DataTaskPublisher.Failure>
       dataPublisher = URLSession.shared.dataTaskPublisher(for: url!)
            .eraseToAnyPublisher()
        return dataPublisher
            .tryMap { output in
                guard let httpResponse = output.response as? HTTPURLResponse else {
                    throw APIError.invalidResponse
                }
                guard (200..<300).contains(httpResponse.statusCode) else {
                    throw APIError.statusCode(httpResponse.statusCode)
                }
                return output.data

            }

(If I try to rewrite the code in imperative way, the tests works fine)

surpher commented 3 years ago

How are you subscribing to this publisher and sending a trigger to execute the network call? How are you collecting the events your dataPublisher is emitting?

ManaliM27 commented 3 years ago

There was some issue in setting the tests. So closing this issue.