fix sonar problems about regular expression
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user