1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package utils
import (
"net/http"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
type readCloserTestImpl struct{}
func (r *readCloserTestImpl) Read(_ []byte) (n int, err error) {
return 0, nil
}
func (r *readCloserTestImpl) Close() error {
return nil
}
// Just to make sure we don't panic, return err and not
// username and pass and cover the function.
func TestHttpReqToString(t *testing.T) {
req := &http.Request{
URL: &url.URL{Host: "localhost:2374", Path: "/unittest"},
Method: http.MethodDelete,
Cancel: make(chan struct{}),
Body: &readCloserTestImpl{},
}
assert.True(t, len(DumpHTTPRequest(req)) > 0)
}
|