Closed flotter closed 10 months ago
I will take a slightly different approach as used elsewhere in Pebble:
func (s *BasePebbleSuite) RedirectClientToTestServer(handler func(http.ResponseWriter, *http.Request)) {
server := httptest.NewServer(http.HandlerFunc(handler))
s.BaseTest.AddCleanup(func() { server.Close() })
cli.ClientConfig.BaseURL = server.URL
s.BaseTest.AddCleanup(func() { cli.ClientConfig.BaseURL = "" })
}
The client test suite used by all client command tests fakes the
doer
today, which is a private internalRequester
implementation detail. Derived projects using the clientRequester
for extended commands needs to fake the Requester interface.This PR adds a client method
SetRequester(rw Requester)
to allow test code to fake the requester. This has to be public to allow an external package to fake this.Pending work remain to properly refactor the existing client test code to Fake the
Requester
instead of thedoer
. This is captured as an outstanding issue here: https://github.com/canonical/pebble/issues/315