make prev/next links omitempty

pull/10616/head
zhulongcheng 2018-12-13 00:01:16 +08:00
parent 6d27a08208
commit 75ce16b633
2 changed files with 3 additions and 7 deletions

View File

@ -70,7 +70,6 @@ func TestService_handleGetBuckets(t *testing.T) {
body: `
{
"links": {
"prev": "",
"self": "/api/v2/buckets?descending=false&limit=1&offset=0",
"next": "/api/v2/buckets?descending=false&limit=1&offset=1"
},
@ -122,9 +121,7 @@ func TestService_handleGetBuckets(t *testing.T) {
body: `
{
"links": {
"prev": "",
"self": "/api/v2/buckets?descending=false&limit=1&offset=0",
"next": ""
"self": "/api/v2/buckets?descending=false&limit=1&offset=0"
},
"buckets": []
}`,
@ -166,7 +163,6 @@ func TestService_handleGetBuckets(t *testing.T) {
if eq, _ := jsonEqual(string(body), tt.wants.body); tt.wants.body != "" && !eq {
t.Errorf("%q. handleGetBuckets() = \n***%v***\n,\nwant\n***%v***", tt.name, string(body), tt.wants.body)
}
})
}
}

View File

@ -17,9 +17,9 @@ type PagingFilter interface {
// PagingLinks represents paging links.
type PagingLinks struct {
Prev string `json:"prev"`
Prev string `json:"prev,omitempty"`
Self string `json:"self"`
Next string `json:"next"`
Next string `json:"next,omitempty"`
}
// FindOptions represents options passed to all find methods with multiple results.