From 1789aec4ad00df0fdcc3e5027ec1f847b21ef61e Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Mon, 3 Dec 2018 14:22:36 -0800 Subject: [PATCH] remove `default` stepMs This way if any query is sent without a step param we simply return an error (as it is a required query param). Fixes #98 --- handlers.go | 4 ++-- handlers_test.go | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/handlers.go b/handlers.go index d740a6c73..dd36039a5 100644 --- a/handlers.go +++ b/handlers.go @@ -917,8 +917,8 @@ func alignStepBoundaries(start int64, end int64, stepMS int64, now int64) (int64 } // Failsafe to 60s if something inexplicably happened to the step param - if stepMS == 0 { - stepMS = 60000 + if stepMS <= 0 { + return 0, 0, fmt.Errorf("step must be > 0") } // Align start/end to step boundaries diff --git a/handlers_test.go b/handlers_test.go index 190eafe74..3d5cc65d4 100644 --- a/handlers_test.go +++ b/handlers_test.go @@ -502,20 +502,30 @@ func TestAlignStepBoundaries(t *testing.T) { 0, 0, true, }, - // query with start and end after now { 2000, 3000, 10, 1, 0, 0, true, }, - // query with start and end after now, with start after end { 3000, 2000, 10, 1, 0, 0, true, }, + // query with no step + { + 1, 100, 0, 1, + 0, 0, + true, + }, + // query with negative step + { + 1, 100, -10, 1, + 0, 0, + true, + }, } for i, test := range tests {