Skip to content

Commit

Permalink
fixes #3038
Browse files Browse the repository at this point in the history
🐞 [Bug]: v3 Flash Message with redirect is not working #3038
  • Loading branch information
ReneWerner87 committed Jun 27, 2024
1 parent a29d65e commit a8e36ee
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ func Benchmark_Redirect_Route_WithFlashMessages(b *testing.B) {
require.Equal(b, "fiber_flash=; expires=Tue, 10 Nov 2009 23:00:00 GMT", c.GetRespHeader(HeaderSetCookie))
}

// go test -v -run=^$ -bench=Benchmark_Redirect_setFlash -benchmem -count=4
func Benchmark_Redirect_setFlash(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_Redirect_parseAndClearFlashMessages -benchmem -count=4
func Benchmark_Redirect_parseAndClearFlashMessages(b *testing.B) {
app := New()
app.Get("/user", func(c Ctx) error {
return c.SendString("user")
Expand Down Expand Up @@ -490,6 +490,27 @@ func Benchmark_Redirect_setFlash(b *testing.B) {
require.Equal(b, map[string]string{"id": "1", "name": "tom"}, c.Redirect().OldInputs())
}

// go test -v -run=^$ -bench=Benchmark_Redirect_processFlashMessages -benchmem -count=4
func Benchmark_Redirect_processFlashMessages(b *testing.B) {
app := New()
app.Get("/user", func(c Ctx) error {
return c.SendString("user")
}).Name("user")

c := app.AcquireCtx(&fasthttp.RequestCtx{}).(*DefaultCtx) //nolint:errcheck, forcetypeassert // not needed

c.Redirect().With("success", "1").With("message", "test")

b.ReportAllocs()
b.ResetTimer()

for n := 0; n < b.N; n++ {
c.Redirect().processFlashMessages()
}

require.Equal(b, "fiber_flash=success:1,message:test; path=/; SameSite=Lax", c.GetRespHeader(HeaderSetCookie))
}

// go test -v -run=^$ -bench=Benchmark_Redirect_Messages -benchmem -count=4
func Benchmark_Redirect_Messages(b *testing.B) {
app := New()
Expand Down

0 comments on commit a8e36ee

Please sign in to comment.