borchero / Squid

Declarative and Reactive Networking for Swift.
https://squid.borchero.com
MIT License
71 stars 6 forks source link

Mock requests for testing #28

Open jessegrosjean opened 3 years ago

jessegrosjean commented 3 years ago

I'm trying to Mock endpoints with Squid and Mocker.

Here's the basic pattern of what I think I want to do:

import Mocker
import Squid

extension HttpService {
    func mock<R>(request: R, statusCode: Int = 200, data: [Mock.HTTPMethod : Data]) where R: Request {
        Mock(url: ..., dataType: .json, statusCode: statusCode, data: data)
    }
}

The problem I'm not sure how to generate a final URL from a Squid Request and Squid HttpService. I know it does this internally, but I can't figure how to to make it generate the URL myself. Is there some method that I'm overlooking? Or is this something that could be added?