More tests

This commit is contained in:
Pavel 2019-10-25 13:18:43 +03:00
parent 37a4c72a4b
commit f9c4a5d462
2 changed files with 37 additions and 0 deletions

View File

@ -147,6 +147,39 @@ func (e *EngineTest) Test_ConfigureRouter() {
})
}
func (e *EngineTest) Test_BuildHTTPClient() {
e.engine.Config = &Config{
HTTPClientConfig: &HTTPClientConfig{
Timeout: 30,
SSLVerification: true,
},
}
e.engine.BuildHTTPClient()
assert.NotNil(e.T(), e.engine.httpClient)
}
func (e *EngineTest) Test_SetHTTPClient() {
var err error
e.engine.httpClient = nil
e.engine.httpClient, err = NewHTTPClientBuilder().Build()
assert.NoError(e.T(), err)
assert.NotNil(e.T(), e.engine.httpClient)
}
func (e *EngineTest) Test_HTTPClient() {
var err error
e.engine.httpClient = nil
assert.NotNil(e.T(), e.engine.HTTPClient())
e.engine.httpClient, err = NewHTTPClientBuilder().Build()
assert.NoError(e.T(), err)
assert.NotNil(e.T(), e.engine.httpClient)
}
func (e *EngineTest) Test_Run_Fail() {
defer func() {
assert.NotNil(e.T(), recover())

View File

@ -149,6 +149,10 @@ func (b *HTTPClientBuilder) buildDialer() *HTTPClientBuilder {
// parseAddress parses address and returns error in case of error (port is necessary)
func (b *HTTPClientBuilder) parseAddress() error {
if b.mockAddress == "" {
return nil
}
if host, port, err := net.SplitHostPort(b.mockAddress); err == nil {
b.mockHost = host
b.mockPort = port