Merge pull request #4677 from Codexiaoyi/develop
fix sonar problems about regular expression
This commit is contained in:
commit
61f5ce8c6c
@ -55,6 +55,7 @@
|
||||
|
||||
## Fix Sonar
|
||||
|
||||
- [4677](https://github.com/beego/beego/pull/4677)
|
||||
- [4624](https://github.com/beego/beego/pull/4624)
|
||||
- [4608](https://github.com/beego/beego/pull/4608)
|
||||
- [4473](https://github.com/beego/beego/pull/4473)
|
||||
|
||||
2
client/cache/redis/redis_test.go
vendored
2
client/cache/redis/redis_test.go
vendored
@ -102,7 +102,7 @@ func TestRedisCache(t *testing.T) {
|
||||
assert.Nil(t, bm.ClearAll(context.Background()))
|
||||
}
|
||||
|
||||
func TestCache_Scan(t *testing.T) {
|
||||
func TestCacheScan(t *testing.T) {
|
||||
timeoutDuration := 10 * time.Second
|
||||
|
||||
addr := os.Getenv("REDIS_ADDR")
|
||||
|
||||
@ -37,7 +37,7 @@ func (r *respCarrier) String() string {
|
||||
return string(r.bytes)
|
||||
}
|
||||
|
||||
func TestOption_WithEnableCookie(t *testing.T) {
|
||||
func TestOptionWithEnableCookie(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/",
|
||||
WithEnableCookie(true))
|
||||
if err != nil {
|
||||
@ -64,7 +64,7 @@ func TestOption_WithEnableCookie(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithUserAgent(t *testing.T) {
|
||||
func TestOptionWithUserAgent(t *testing.T) {
|
||||
v := "beego"
|
||||
client, err := NewClient("test", "http://httpbin.org/",
|
||||
WithUserAgent(v))
|
||||
@ -85,7 +85,7 @@ func TestOption_WithUserAgent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithCheckRedirect(t *testing.T) {
|
||||
func TestOptionWithCheckRedirect(t *testing.T) {
|
||||
client, err := NewClient("test", "https://goolnk.com/33BD2j",
|
||||
WithCheckRedirect(func(redirectReq *http.Request, redirectVia []*http.Request) error {
|
||||
return errors.New("Redirect triggered")
|
||||
@ -97,7 +97,7 @@ func TestOption_WithCheckRedirect(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestOption_WithHTTPSetting(t *testing.T) {
|
||||
func TestOptionWithHTTPSetting(t *testing.T) {
|
||||
v := "beego"
|
||||
var setting BeegoHTTPSettings
|
||||
setting.EnableCookie = true
|
||||
@ -133,7 +133,7 @@ func TestOption_WithHTTPSetting(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithHeader(t *testing.T) {
|
||||
func TestOptionWithHeader(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -153,7 +153,7 @@ func TestOption_WithHeader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithTokenFactory(t *testing.T) {
|
||||
func TestOptionWithTokenFactory(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -176,7 +176,7 @@ func TestOption_WithTokenFactory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithBasicAuth(t *testing.T) {
|
||||
func TestOptionWithBasicAuth(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -197,7 +197,7 @@ func TestOption_WithBasicAuth(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithContentType(t *testing.T) {
|
||||
func TestOptionWithContentType(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -217,7 +217,7 @@ func TestOption_WithContentType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithParam(t *testing.T) {
|
||||
func TestOptionWithParam(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -237,7 +237,7 @@ func TestOption_WithParam(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOption_WithRetry(t *testing.T) {
|
||||
func TestOptionWithRetry(t *testing.T) {
|
||||
client, err := NewClient("test", "https://goolnk.com/33BD2j",
|
||||
WithCheckRedirect(func(redirectReq *http.Request, redirectVia []*http.Request) error {
|
||||
return errors.New("Redirect triggered")
|
||||
|
||||
@ -80,7 +80,7 @@ type slide struct {
|
||||
Title string `json:"title" yaml:"title" xml:"title"`
|
||||
}
|
||||
|
||||
func TestClient_handleCarrier(t *testing.T) {
|
||||
func TestClientHandleCarrier(t *testing.T) {
|
||||
v := "beego"
|
||||
client, err := NewClient("test", "http://httpbin.org/",
|
||||
WithUserAgent(v))
|
||||
@ -108,7 +108,7 @@ func TestClient_handleCarrier(t *testing.T) {
|
||||
assert.Equal(t, s.String(), string(b))
|
||||
}
|
||||
|
||||
func TestClient_Get(t *testing.T) {
|
||||
func TestClientGet(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -145,7 +145,7 @@ func TestClient_Get(t *testing.T) {
|
||||
assert.Equal(t, "Overview", s.Slideshow.Slides[1].Title)
|
||||
}
|
||||
|
||||
func TestClient_Post(t *testing.T) {
|
||||
func TestClientPost(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -166,7 +166,7 @@ func TestClient_Post(t *testing.T) {
|
||||
assert.Equal(t, http.MethodPost, resp.Resp.Request.Method)
|
||||
}
|
||||
|
||||
func TestClient_Put(t *testing.T) {
|
||||
func TestClientPut(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -187,7 +187,7 @@ func TestClient_Put(t *testing.T) {
|
||||
assert.Equal(t, http.MethodPut, resp.Resp.Request.Method)
|
||||
}
|
||||
|
||||
func TestClient_Delete(t *testing.T) {
|
||||
func TestClientDelete(t *testing.T) {
|
||||
client, err := NewClient("test", "http://httpbin.org")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -203,7 +203,7 @@ func TestClient_Delete(t *testing.T) {
|
||||
assert.Equal(t, http.MethodDelete, resp.Resp.Request.Method)
|
||||
}
|
||||
|
||||
func TestClient_Head(t *testing.T) {
|
||||
func TestClientHead(t *testing.T) {
|
||||
client, err := NewClient("test", "http://beego.me")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@ -433,5 +433,5 @@ func TestBeegoHTTPRequestXMLBody(t *testing.T) {
|
||||
}
|
||||
|
||||
// TODO
|
||||
func TestBeegoHTTPRequest_ResponseForValue(t *testing.T) {
|
||||
func TestBeegoHTTPRequestResponseForValue(t *testing.T) {
|
||||
}
|
||||
|
||||
@ -23,13 +23,13 @@ import (
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
)
|
||||
|
||||
func TestSimpleCondition_MatchPath(t *testing.T) {
|
||||
func TestSimpleConditionMatchPath(t *testing.T) {
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
res := sc.Match(context.Background(), httplib.Get("http://localhost:8080/abc/s"))
|
||||
assert.True(t, res)
|
||||
}
|
||||
|
||||
func TestSimpleCondition_MatchQuery(t *testing.T) {
|
||||
func TestSimpleConditionMatchQuery(t *testing.T) {
|
||||
k, v := "my-key", "my-value"
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
res := sc.Match(context.Background(), httplib.Get("http://localhost:8080/abc/s?my-key=my-value"))
|
||||
@ -49,7 +49,7 @@ func TestSimpleCondition_MatchQuery(t *testing.T) {
|
||||
assert.True(t, res)
|
||||
}
|
||||
|
||||
func TestSimpleCondition_MatchHeader(t *testing.T) {
|
||||
func TestSimpleConditionMatchHeader(t *testing.T) {
|
||||
k, v := "my-header", "my-header-value"
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
req := httplib.Get("http://localhost:8080/abc/s")
|
||||
@ -67,7 +67,7 @@ func TestSimpleCondition_MatchHeader(t *testing.T) {
|
||||
assert.False(t, sc.Match(context.Background(), req))
|
||||
}
|
||||
|
||||
func TestSimpleCondition_MatchBodyField(t *testing.T) {
|
||||
func TestSimpleConditionMatchBodyField(t *testing.T) {
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
req := httplib.Post("http://localhost:8080/abc/s")
|
||||
|
||||
@ -96,7 +96,7 @@ func TestSimpleCondition_MatchBodyField(t *testing.T) {
|
||||
assert.True(t, sc.Match(context.Background(), req))
|
||||
}
|
||||
|
||||
func TestSimpleCondition_Match(t *testing.T) {
|
||||
func TestSimpleConditionMatch(t *testing.T) {
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
req := httplib.Post("http://localhost:8080/abc/s")
|
||||
|
||||
@ -109,7 +109,7 @@ func TestSimpleCondition_Match(t *testing.T) {
|
||||
assert.False(t, sc.Match(context.Background(), req))
|
||||
}
|
||||
|
||||
func TestSimpleCondition_MatchPathReg(t *testing.T) {
|
||||
func TestSimpleConditionMatchPathReg(t *testing.T) {
|
||||
sc := NewSimpleCondition("", WithPathReg(`\/abc\/.*`))
|
||||
req := httplib.Post("http://localhost:8080/abc/s")
|
||||
assert.True(t, sc.Match(context.Background(), req))
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
)
|
||||
|
||||
func TestMockResponseFilter_FilterChain(t *testing.T) {
|
||||
func TestMockResponseFilterFilterChain(t *testing.T) {
|
||||
req := httplib.Get("http://localhost:8080/abc/s")
|
||||
ft := NewMockResponseFilter()
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ func TestStartMock(t *testing.T) {
|
||||
|
||||
// TestStartMock_Isolation Test StartMock that
|
||||
// mock only work for this request
|
||||
func TestStartMock_Isolation(t *testing.T) {
|
||||
func TestStartMockIsolation(t *testing.T) {
|
||||
// httplib.defaultSetting.FilterChains = []httplib.FilterChain{mockFilter.FilterChain}
|
||||
// setup global stub
|
||||
stub := StartMock()
|
||||
|
||||
@ -108,7 +108,7 @@ func TestParseOrder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrder_GetColumn(t *testing.T) {
|
||||
func TestOrderGetColumn(t *testing.T) {
|
||||
o := Clause(
|
||||
Column(`user__id`),
|
||||
)
|
||||
|
||||
@ -35,7 +35,7 @@ func TestRegisterDataBase(t *testing.T) {
|
||||
assert.Equal(t, al.ConnMaxLifetime, time.Minute)
|
||||
}
|
||||
|
||||
func TestRegisterDataBase_MaxStmtCacheSizeNegative1(t *testing.T) {
|
||||
func TestRegisterDataBaseMaxStmtCacheSizeNegative1(t *testing.T) {
|
||||
aliasName := "TestRegisterDataBase_MaxStmtCacheSizeNegative1"
|
||||
err := RegisterDataBase(aliasName, DBARGS.Driver, DBARGS.Source, MaxStmtCacheSize(-1))
|
||||
assert.Nil(t, err)
|
||||
@ -45,7 +45,7 @@ func TestRegisterDataBase_MaxStmtCacheSizeNegative1(t *testing.T) {
|
||||
assert.Equal(t, al.DB.stmtDecoratorsLimit, 0)
|
||||
}
|
||||
|
||||
func TestRegisterDataBase_MaxStmtCacheSize0(t *testing.T) {
|
||||
func TestRegisterDataBaseMaxStmtCacheSize0(t *testing.T) {
|
||||
aliasName := "TestRegisterDataBase_MaxStmtCacheSize0"
|
||||
err := RegisterDataBase(aliasName, DBARGS.Driver, DBARGS.Source, MaxStmtCacheSize(0))
|
||||
assert.Nil(t, err)
|
||||
@ -55,7 +55,7 @@ func TestRegisterDataBase_MaxStmtCacheSize0(t *testing.T) {
|
||||
assert.Equal(t, al.DB.stmtDecoratorsLimit, 0)
|
||||
}
|
||||
|
||||
func TestRegisterDataBase_MaxStmtCacheSize1(t *testing.T) {
|
||||
func TestRegisterDataBaseMaxStmtCacheSize1(t *testing.T) {
|
||||
aliasName := "TestRegisterDataBase_MaxStmtCacheSize1"
|
||||
err := RegisterDataBase(aliasName, DBARGS.Driver, DBARGS.Source, MaxStmtCacheSize(1))
|
||||
assert.Nil(t, err)
|
||||
@ -65,7 +65,7 @@ func TestRegisterDataBase_MaxStmtCacheSize1(t *testing.T) {
|
||||
assert.Equal(t, al.DB.stmtDecoratorsLimit, 1)
|
||||
}
|
||||
|
||||
func TestRegisterDataBase_MaxStmtCacheSize841(t *testing.T) {
|
||||
func TestRegisterDataBaseMaxStmtCacheSize841(t *testing.T) {
|
||||
aliasName := "TestRegisterDataBase_MaxStmtCacheSize841"
|
||||
err := RegisterDataBase(aliasName, DBARGS.Driver, DBARGS.Source, MaxStmtCacheSize(841))
|
||||
assert.Nil(t, err)
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func TestDefaultValueFilterChainBuilder_FilterChain(t *testing.T) {
|
||||
func TestDefaultValueFilterChainBuilderFilterChain(t *testing.T) {
|
||||
builder := NewDefaultValueFilterChainBuilder(nil, true, true)
|
||||
o := orm.NewFilterOrmDecorator(&defaultValueTestOrm{}, builder.FilterChain)
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func TestFilterChainBuilder_FilterChain(t *testing.T) {
|
||||
func TestFilterChainBuilderFilterChain(t *testing.T) {
|
||||
next := func(ctx context.Context, inv *orm.Invocation) []interface{} {
|
||||
inv.TxName = "Hello"
|
||||
return []interface{}{}
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func TestFilterChainBuilder_FilterChain1(t *testing.T) {
|
||||
func TestFilterChainBuilderFilterChain1(t *testing.T) {
|
||||
next := func(ctx context.Context, inv *orm.Invocation) []interface{} {
|
||||
inv.Method = "coming"
|
||||
return []interface{}{}
|
||||
|
||||
@ -26,7 +26,7 @@ import (
|
||||
"github.com/beego/beego/v2/core/utils"
|
||||
)
|
||||
|
||||
func TestFilterOrmDecorator_Read(t *testing.T) {
|
||||
func TestFilterOrmDecoratorRead(t *testing.T) {
|
||||
register()
|
||||
|
||||
o := &filterMockOrm{}
|
||||
@ -45,7 +45,7 @@ func TestFilterOrmDecorator_Read(t *testing.T) {
|
||||
assert.Equal(t, "read error", err.Error())
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_BeginTx(t *testing.T) {
|
||||
func TestFilterOrmDecoratorBeginTx(t *testing.T) {
|
||||
register()
|
||||
|
||||
o := &filterMockOrm{}
|
||||
@ -95,7 +95,7 @@ func TestFilterOrmDecorator_BeginTx(t *testing.T) {
|
||||
assert.Equal(t, "rollback", err.Error())
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_DBStats(t *testing.T) {
|
||||
func TestFilterOrmDecoratorDBStats(t *testing.T) {
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
return func(ctx context.Context, inv *Invocation) []interface{} {
|
||||
@ -110,7 +110,7 @@ func TestFilterOrmDecorator_DBStats(t *testing.T) {
|
||||
assert.Equal(t, -1, res.MaxOpenConnections)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_Delete(t *testing.T) {
|
||||
func TestFilterOrmDecoratorDelete(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -127,7 +127,7 @@ func TestFilterOrmDecorator_Delete(t *testing.T) {
|
||||
assert.Equal(t, int64(-2), res)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_DoTx(t *testing.T) {
|
||||
func TestFilterOrmDecoratorDoTx(t *testing.T) {
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
return func(ctx context.Context, inv *Invocation) []interface{} {
|
||||
@ -174,7 +174,7 @@ func TestFilterOrmDecorator_DoTx(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_Driver(t *testing.T) {
|
||||
func TestFilterOrmDecoratorDriver(t *testing.T) {
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
return func(ctx context.Context, inv *Invocation) []interface{} {
|
||||
@ -189,7 +189,7 @@ func TestFilterOrmDecorator_Driver(t *testing.T) {
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_Insert(t *testing.T) {
|
||||
func TestFilterOrmDecoratorInsert(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -208,7 +208,7 @@ func TestFilterOrmDecorator_Insert(t *testing.T) {
|
||||
assert.Equal(t, int64(100), i)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_InsertMulti(t *testing.T) {
|
||||
func TestFilterOrmDecoratorInsertMulti(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -228,7 +228,7 @@ func TestFilterOrmDecorator_InsertMulti(t *testing.T) {
|
||||
assert.Equal(t, int64(2), i)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_InsertOrUpdate(t *testing.T) {
|
||||
func TestFilterOrmDecoratorInsertOrUpdate(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -246,7 +246,7 @@ func TestFilterOrmDecorator_InsertOrUpdate(t *testing.T) {
|
||||
assert.Equal(t, int64(1), i)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_LoadRelated(t *testing.T) {
|
||||
func TestFilterOrmDecoratorLoadRelated(t *testing.T) {
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
return func(ctx context.Context, inv *Invocation) []interface{} {
|
||||
@ -263,7 +263,7 @@ func TestFilterOrmDecorator_LoadRelated(t *testing.T) {
|
||||
assert.Equal(t, int64(99), i)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_QueryM2M(t *testing.T) {
|
||||
func TestFilterOrmDecoratorQueryM2M(t *testing.T) {
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
return func(ctx context.Context, inv *Invocation) []interface{} {
|
||||
@ -278,7 +278,7 @@ func TestFilterOrmDecorator_QueryM2M(t *testing.T) {
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_QueryTable(t *testing.T) {
|
||||
func TestFilterOrmDecoratorQueryTable(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -294,7 +294,7 @@ func TestFilterOrmDecorator_QueryTable(t *testing.T) {
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_Raw(t *testing.T) {
|
||||
func TestFilterOrmDecoratorRaw(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -310,7 +310,7 @@ func TestFilterOrmDecorator_Raw(t *testing.T) {
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_ReadForUpdate(t *testing.T) {
|
||||
func TestFilterOrmDecoratorReadForUpdate(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
@ -327,7 +327,7 @@ func TestFilterOrmDecorator_ReadForUpdate(t *testing.T) {
|
||||
assert.Equal(t, "read for update error", err.Error())
|
||||
}
|
||||
|
||||
func TestFilterOrmDecorator_ReadOrCreate(t *testing.T) {
|
||||
func TestFilterOrmDecoratorReadOrCreate(t *testing.T) {
|
||||
register()
|
||||
o := &filterMockOrm{}
|
||||
od := NewFilterOrmDecorator(o, func(next Filter) Filter {
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewHint_time(t *testing.T) {
|
||||
func TestNewHintTime(t *testing.T) {
|
||||
key := "qweqwe"
|
||||
value := time.Second
|
||||
hint := NewHint(key, value)
|
||||
@ -30,7 +30,7 @@ func TestNewHint_time(t *testing.T) {
|
||||
assert.Equal(t, hint.GetValue(), value)
|
||||
}
|
||||
|
||||
func TestNewHint_int(t *testing.T) {
|
||||
func TestNewHintInt(t *testing.T) {
|
||||
key := "qweqwe"
|
||||
value := 281230
|
||||
hint := NewHint(key, value)
|
||||
@ -39,7 +39,7 @@ func TestNewHint_int(t *testing.T) {
|
||||
assert.Equal(t, hint.GetValue(), value)
|
||||
}
|
||||
|
||||
func TestNewHint_float(t *testing.T) {
|
||||
func TestNewHintFloat(t *testing.T) {
|
||||
key := "qweqwe"
|
||||
value := 21.2459753
|
||||
hint := NewHint(key, value)
|
||||
@ -55,7 +55,7 @@ func TestForceIndex(t *testing.T) {
|
||||
assert.Equal(t, hint.GetKey(), KeyForceIndex)
|
||||
}
|
||||
|
||||
func TestForceIndex_0(t *testing.T) {
|
||||
func TestForceIndex0(t *testing.T) {
|
||||
var s []string
|
||||
hint := ForceIndex(s...)
|
||||
assert.Equal(t, hint.GetValue(), s)
|
||||
@ -69,7 +69,7 @@ func TestIgnoreIndex(t *testing.T) {
|
||||
assert.Equal(t, hint.GetKey(), KeyIgnoreIndex)
|
||||
}
|
||||
|
||||
func TestIgnoreIndex_0(t *testing.T) {
|
||||
func TestIgnoreIndex0(t *testing.T) {
|
||||
var s []string
|
||||
hint := IgnoreIndex(s...)
|
||||
assert.Equal(t, hint.GetValue(), s)
|
||||
@ -83,7 +83,7 @@ func TestUseIndex(t *testing.T) {
|
||||
assert.Equal(t, hint.GetKey(), KeyUseIndex)
|
||||
}
|
||||
|
||||
func TestUseIndex_0(t *testing.T) {
|
||||
func TestUseIndex0(t *testing.T) {
|
||||
var s []string
|
||||
hint := UseIndex(s...)
|
||||
assert.Equal(t, hint.GetValue(), s)
|
||||
|
||||
@ -29,7 +29,7 @@ func (n *NotApplicableModel) IsApplicableTableForDB(db string) bool {
|
||||
return db == "default"
|
||||
}
|
||||
|
||||
func Test_IsApplicableTableForDB(t *testing.T) {
|
||||
func TestIsApplicableTableForDB(t *testing.T) {
|
||||
assert.False(t, isApplicableTableForDB(reflect.ValueOf(&NotApplicableModel{}), "defa"))
|
||||
assert.True(t, isApplicableTableForDB(reflect.ValueOf(&NotApplicableModel{}), "default"))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user