github.com/kubeshop/testkube@v1.17.23/pkg/cloud/client/client_mock_test.go (about) 1 package client 2 3 import ( 4 "bytes" 5 "io" 6 "net/http" 7 ) 8 9 type ClientMock struct { 10 body []byte 11 err error 12 validateRequestFunc func(req *http.Request) error 13 } 14 15 func (c ClientMock) Do(req *http.Request) (*http.Response, error) { 16 err := c.validateRequestFunc(req) 17 if err != nil { 18 return nil, err 19 } 20 return &http.Response{ 21 Body: io.NopCloser(bytes.NewReader(c.body)), 22 }, c.err 23 }