MSP-8974 fix tests
This commit is contained in:
1 parent
71498785ea
commit
fa8bc6c1b7
50 files changed
+392
-2975
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
package httpt
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/txix-open/isp-kit/http/httpcli"
|
||||
"github.com/txix-open/isp-kit/http/httpclix"
|
||||
"github.com/txix-open/isp-kit/test"
|
||||
)
|
||||
|
||||
// TestServer creates and starts an HTTP test server with the provided handler,
|
||||
// returning both the server and a configured client. The server listens on
|
||||
// a random local port and the client is pre-configured with the server's URL.
|
||||
func TestServer(t *test.Test, handler http.Handler, opts ...httpcli.Option) (*httptest.Server, *httpcli.Client) {
|
||||
srv := httptest.NewServer(handler)
|
||||
cli := httpclix.Default(opts...)
|
||||
cli.GlobalRequestConfig().BaseUrl = srv.URL
|
||||
return srv, cli
|
||||
}
|
||||
Reference in new issue
Block a user