未验证 提交 97091615 编写于 作者: H huanggze

fix isRangeQuery

Signed-off-by: Nhuanggze <loganhuang@yunify.com>
上级 6ef372a9
......@@ -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 {
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册