Skip to content

Commit

Permalink
remove default stepMs
Browse files Browse the repository at this point in the history
This way if any query is sent without a step param we simply return an
error (as it is a required query param).

Fixes trickstercache#98
  • Loading branch information
jacksontj committed Dec 3, 2018
1 parent c7d8c6b commit 1789aec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1789aec

Please sign in to comment.