Closed Ch00k closed 3 years ago
Hi. There is a url
method in the MockServer
structure (this method), as shown in this example. Does that solve your problem?
Well, I just realized that I could do mock_server.url("")
, and that will get me the base URL :)
I am implementing a REST client, and using httpmock to test it. I instantiate my client by passing the address of the server (base URL), which is an HTTP(S) URL, like so:
Then my client implements various methods, that send HTTP requests to various paths, relative to the base URL. In each of my tests, in order to instantiate my client, I have to compile the base URL manually every time:
Not such a big deal really, it's only one line, but I thought that for convenience
MockServer
could expose the base URL in a method. For example by making thepath
argument inurl
function optional (ifpath
isNone
, return the base URL).If that makes sense, I'd be more than happy to make a PR. I am very new to Rust, so it could be that the way I am designing my client (or the way I am testing it) is suboptimal. I'd appreciate an advice on how to do it the right way :)