未验证 提交 3f89eaef 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #2016 from huanggze/dev-fix

fix isRangeQuery
......@@ -71,7 +71,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.
先完成此消息的编辑!
想要评论请 注册