mirror of
https://github.com/retailcrm/mg-transport-core.git
synced 2024-11-22 05:06:04 +03:00
better engine coverage
This commit is contained in:
parent
990f4f0697
commit
b82d4e8258
@ -173,27 +173,6 @@ func (e *EngineTest) Test_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_WithCookieSessions() {
|
||||
e.engine.Sessions = nil
|
||||
e.engine.WithCookieSessions(4)
|
||||
@ -208,6 +187,55 @@ func (e *EngineTest) Test_WithFilesystemSessions() {
|
||||
assert.NotNil(e.T(), e.engine.Sessions)
|
||||
}
|
||||
|
||||
func (e *EngineTest) Test_UnsafeLogger() {
|
||||
origLogger := e.engine.logger
|
||||
defer func() {
|
||||
e.engine.logger = origLogger
|
||||
}()
|
||||
e.engine.logger = nil
|
||||
assert.Nil(e.T(), e.engine.UnsafeLogger())
|
||||
e.engine.logger = &Logger{}
|
||||
assert.IsType(e.T(), &Logger{}, e.engine.UnsafeLogger())
|
||||
}
|
||||
|
||||
func (e *EngineTest) Test_SetLogger() {
|
||||
origLogger := e.engine.logger
|
||||
defer func() {
|
||||
e.engine.logger = origLogger
|
||||
}()
|
||||
e.engine.logger = &Logger{}
|
||||
e.engine.SetLogger(nil)
|
||||
assert.NotNil(e.T(), e.engine.logger)
|
||||
}
|
||||
|
||||
func (e *EngineTest) Test_SetHTTPClient() {
|
||||
origClient := e.engine.httpClient
|
||||
defer func() {
|
||||
e.engine.httpClient = origClient
|
||||
}()
|
||||
e.engine.httpClient = nil
|
||||
httpClient, err := NewHTTPClientBuilder().Build()
|
||||
require.NoError(e.T(), err)
|
||||
assert.NotNil(e.T(), httpClient)
|
||||
e.engine.SetHTTPClient(&http.Client{})
|
||||
require.NotNil(e.T(), e.engine.httpClient)
|
||||
e.engine.SetHTTPClient(nil)
|
||||
assert.NotNil(e.T(), e.engine.httpClient)
|
||||
}
|
||||
|
||||
func (e *EngineTest) Test_HTTPClient() {
|
||||
origClient := e.engine.httpClient
|
||||
defer func() {
|
||||
e.engine.httpClient = origClient
|
||||
}()
|
||||
e.engine.httpClient = nil
|
||||
require.Same(e.T(), http.DefaultClient, e.engine.HTTPClient())
|
||||
httpClient, err := NewHTTPClientBuilder().Build()
|
||||
require.NoError(e.T(), err)
|
||||
e.engine.httpClient = httpClient
|
||||
assert.Same(e.T(), httpClient, e.engine.HTTPClient())
|
||||
}
|
||||
|
||||
func (e *EngineTest) Test_InitCSRF_Fail() {
|
||||
defer func() {
|
||||
assert.NotNil(e.T(), recover())
|
||||
|
1
go.sum
1
go.sum
@ -215,6 +215,7 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
|
Loading…
Reference in New Issue
Block a user