-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(be): search by status on the route list page is invalid #1207
Changes from 8 commits
6c49aa3
7e2b56f
db468cb
9d2d9e7
b3f2a51
b1179ba
27eba5c
dd955bd
b8ad7d1
6ec1338
24eb08c
06ab54f
a17dd2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ func TestRoute(t *testing.T) { | |
"vars": [], | ||
"remote_addrs": ["127.0.0.0/8"], | ||
"methods": ["PUT", "GET"], | ||
"status": 1, | ||
"upstream": { | ||
"type": "roundrobin", | ||
"nodes": [{ | ||
|
@@ -415,6 +416,7 @@ func TestRoute(t *testing.T) { | |
"hosts": ["foo.com", "*.bar.com"], | ||
"remote_addrs": ["127.0.0.0/8"], | ||
"methods": ["PUT", "GET"], | ||
"status": 1, | ||
"labels": { | ||
"l1": "v1", | ||
"l2": "v2" | ||
|
@@ -925,6 +927,42 @@ func TestRoute(t *testing.T) { | |
dataPage = retPage.(*store.ListOutput) | ||
assert.Equal(t, len(dataPage.Rows), 0) | ||
|
||
// list search and status match | ||
listInput = &ListInput{} | ||
reqBody = `{"page_size": 1, "page": 1, "status": "1"}` | ||
err = json.Unmarshal([]byte(reqBody), listInput) | ||
assert.Nil(t, err) | ||
ctx.SetInput(listInput) | ||
retPage, err = handler.List(ctx) | ||
assert.Nil(t, err) | ||
dataPage = retPage.(*store.ListOutput) | ||
assert.Equal(t, len(dataPage.Rows), 1) | ||
|
||
//sleep | ||
time.Sleep(time.Duration(100) * time.Millisecond) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style: redundant space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @Jaycean don't forget to fix the style problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
|
||
// list search and status not match | ||
listInput = &ListInput{} | ||
reqBody = `{"page_size": 1, "page": 1, "name": "a", "status": "0"}` | ||
err = json.Unmarshal([]byte(reqBody), listInput) | ||
assert.Nil(t, err) | ||
ctx.SetInput(listInput) | ||
retPage, err = handler.List(ctx) | ||
assert.Nil(t, err) | ||
dataPage = retPage.(*store.ListOutput) | ||
assert.Equal(t, len(dataPage.Rows), 0) | ||
|
||
//list search with name and status | ||
listInput = &ListInput{} | ||
reqBody = `{"page_size": 1, "page": 1, "name": "a", "status": "1"}` | ||
err = json.Unmarshal([]byte(reqBody), listInput) | ||
assert.Nil(t, err) | ||
ctx.SetInput(listInput) | ||
retPage, err = handler.List(ctx) | ||
assert.Nil(t, err) | ||
dataPage = retPage.(*store.ListOutput) | ||
assert.Equal(t, len(dataPage.Rows), 1) | ||
|
||
//list search with name and label | ||
listInput = &ListInput{} | ||
reqBody = `{"page_size": 1, "page": 1, "name": "a", "label":"l1:v1"}` | ||
|
@@ -958,6 +996,17 @@ func TestRoute(t *testing.T) { | |
dataPage = retPage.(*store.ListOutput) | ||
assert.Equal(t, len(dataPage.Rows), 1) | ||
|
||
//list search with uri,name, status and label | ||
listInput = &ListInput{} | ||
reqBody = `{"page_size": 1, "page": 1, "name": "a", "status": "1", "uri": "index", "label":"l1:v1"}` | ||
err = json.Unmarshal([]byte(reqBody), listInput) | ||
assert.Nil(t, err) | ||
ctx.SetInput(listInput) | ||
retPage, err = handler.List(ctx) | ||
assert.Nil(t, err) | ||
dataPage = retPage.(*store.ListOutput) | ||
assert.Equal(t, len(dataPage.Rows), 1) | ||
|
||
//create route using uris | ||
route3 := &entity.Route{} | ||
reqBody = `{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using
strconv.Itoa
instead offmt.Sprintf
. Because the former is faster than the latter in the benchmark test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestion. I'll revise it right away