Skip to content

Commit

Permalink
test(middleware/session): Fix tests for updated panics
Browse files Browse the repository at this point in the history
  • Loading branch information
sixcolors committed Sep 20, 2024
1 parent ec5a698 commit 13a1eb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 1 addition & 11 deletions middleware/session/config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package session

import (
"fmt"
"strings"
"time"

"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/session"
"github.com/gofiber/utils/v2"
)

Expand All @@ -20,7 +18,7 @@ type Config struct {

// Next defines a function to skip this middleware when it returns true.
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
Next func(c fiber.Ctx) bool

// Store defines the session store.
//
Expand Down Expand Up @@ -182,11 +180,3 @@ func configDefault(config ...Config) Config {

return cfg
}

// Example for Config struct.
func ExampleConfig() {
cfg := session.Config{
IdleTimeout: 10 * time.Minute,
}
fmt.Println(cfg.IdleTimeout)
}
4 changes: 2 additions & 2 deletions middleware/session/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func TestDefaultErrorHandler(t *testing.T) {
}

func TestInvalidKeyLookupFormat(t *testing.T) {
require.PanicsWithValue(t, "[session] KeyLookup must in the form of <source>:<name>", func() {
require.PanicsWithValue(t, "[session] KeyLookup must be in the format '<source>:<name>'", func() {
configDefault(Config{KeyLookup: "invalid_format"})
})
}

func TestUnsupportedSource(t *testing.T) {
require.PanicsWithValue(t, "[session] source is not supported", func() {
require.PanicsWithValue(t, "[session] unsupported source in KeyLookup", func() {
configDefault(Config{KeyLookup: "unsupported:session_id"})
})
}

0 comments on commit 13a1eb4

Please sign in to comment.