Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Shareed2k committed Apr 9, 2020
1 parent 9eb3aed commit e791e75
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ go 1.14
require (
github.com/go-redis/redis/v7 v7.2.0
github.com/gofiber/fiber v1.8.431
github.com/shareed2k/go_limiter v0.0.5
github.com/shareed2k/go_limiter v0.0.6
github.com/stretchr/testify v1.5.1
)
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shareed2k/go_limiter v0.0.5 h1:v6JhDd/rp5aGum4HYg7Ko0k/ATQtj91OXP0AsrWuGsY=
github.com/shareed2k/go_limiter v0.0.5/go.mod h1:YD+giVRK4A6t4OpIdsQP716pXuL2+Fp52B7LfyNI5m0=
github.com/shareed2k/go_limiter v0.0.6 h1:iySeSnJ17B4Xs7ctb5Cb5H/ogGbtT66L/GZoMEGFEjA=
github.com/shareed2k/go_limiter v0.0.6/go.mod h1:YD+giVRK4A6t4OpIdsQP716pXuL2+Fp52B7LfyNI5m0=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
Expand Down
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

const (
SimpleAlgorithm = "simple"
GCRAAlgorithm = "gcra"
DefaultKeyPrefix = "fiber_limiter"
SlidingWindowAlgorithm = go_limiter.SlidingWindowAlgorithm
GCRAAlgorithm = go_limiter.GCRAAlgorithm
DefaultKeyPrefix = "fiber_limiter"
)

// Config ...
Expand All @@ -38,8 +38,8 @@ type Config struct {
Message string

// Algorithm
// Default: simple
Algorithm string
// Default: sliding window
Algorithm uint

// Prefix
// Default:
Expand Down Expand Up @@ -99,8 +99,8 @@ func New(config Config) func(*fiber.Ctx) {
}
}

if config.Algorithm == "" {
config.Algorithm = SimpleAlgorithm
if config.Algorithm == 0 {
config.Algorithm = SlidingWindowAlgorithm
}

if config.Period == 0 {
Expand Down
21 changes: 21 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package fiber_limiter

import (
"testing"

"github.com/gofiber/fiber"
"github.com/stretchr/testify/assert"
)

func TestPanicOnNilRediser(t *testing.T) {
ff := func() {
New(Config{})(&fiber.Ctx{})
}

assert.Panics(t, ff, "should panic on rediser nil")
}

func TestSkipOnError(t *testing.T) {
app := fiber.New()

}

0 comments on commit e791e75

Please sign in to comment.