fix isRangeQuery

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2020-04-17 16:48:07 +08:00
parent 6ef372a923
commit 9709161540
2 changed files with 31 additions and 1 deletions

View File

@@ -70,7 +70,7 @@ type queryOptions struct {
}
func (q queryOptions) isRangeQuery() bool {
return !q.time.IsZero()
return q.time.IsZero()
}
func (q queryOptions) shouldSort() bool {

View File

@@ -12,6 +12,36 @@ import (
"time"
)
func TestIsRangeQuery(t *testing.T) {
tests := []struct {
opt queryOptions
expected bool
}{
{
opt: queryOptions{
time: time.Now(),
},
expected: false,
},
{
opt: queryOptions{
start: time.Now().Add(-time.Hour),
end: time.Now(),
},
expected: true,
},
}
for i, tt := range tests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
b := tt.opt.isRangeQuery()
if b != tt.expected {
t.Fatalf("expected %v, but got %v", tt.expected, b)
}
})
}
}
func TestParseRequestParams(t *testing.T) {
tests := []struct {
params reqParams