test: fix most integration tests (live)

This commit is contained in:
James Houlahan
2020-04-09 10:24:58 +02:00
parent bafd4e714e
commit fec5f2d3c3
18 changed files with 124 additions and 104 deletions

View File

@ -24,21 +24,21 @@ import (
"github.com/pkg/errors"
)
func (cntrl *Controller) TurnInternetConnectionOff() {
cntrl.noInternetConnection = true
func (ctl *Controller) TurnInternetConnectionOff() {
ctl.noInternetConnection = true
}
func (cntrl *Controller) TurnInternetConnectionOn() {
cntrl.noInternetConnection = false
func (ctl *Controller) TurnInternetConnectionOn() {
ctl.noInternetConnection = false
}
type fakeTransport struct {
cntrl *Controller
ctl *Controller
transport http.RoundTripper
}
func (t *fakeTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if t.cntrl.noInternetConnection {
if t.ctl.noInternetConnection {
return nil, errors.New("no route to host")
}
@ -53,7 +53,7 @@ func (t *fakeTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, errors.Wrap(err, "failed to read body")
}
}
t.cntrl.recordCall(req.Method, req.URL.Path, body)
t.ctl.recordCall(req.Method, req.URL.Path, body)
return t.transport.RoundTrip(req)
}