Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have a lambda function that would be nice to end-to-end test. It functions as a proxy and receives a URL, resolves it to an IP address and then returns the response to the client. The existing tests use `mockito` for the HTTP responses and point directly to the server, but it would be good to test the DNS resolution in the mix as well. In essence, it would be nice to do something like: ``` let host = "example.com"; let mut http_server = mockito::Server::new(); let mut dns_server = dns_mock_server::Server::new(); let socket_addr = http_server.socket_address(); dns_server.add_records("example.com", vec![socket_addr.ip()]); let port = socket_addr.port(); let uri = format!("http://{host}:{port}"); handle_request(uri); ``` This will then resolve `example.com` into the address of the `mockito` server before making the request to the mock and handling the response. However, `mockito` doesn't currently expose the address of the server in a nice format. While the socket address likely could just be parsed with `SocketAddr::from_str` on the result of `host_with_port`, it makes more sense to expose the `SocketAddr` directly (and begin passing it around instead of `String`). This change: * Updates the `Server` type to store a `SocketAddr` instead of a `String` * Adds a function to get the underlying address
- Loading branch information