Home / File/ session_test.go — fiber Source File

session_test.go — fiber Source File

Architecture documentation for session_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberMiddleware Session 1 imports 25 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  397e6e82_749b_4ef2_9365_02be671c59f7["session_test.go"]
  fcef1725_af89_d6cd_36cd_b228cdcc5acd["errors"]
  397e6e82_749b_4ef2_9365_02be671c59f7 --> fcef1725_af89_d6cd_36cd_b228cdcc5acd
  style 397e6e82_749b_4ef2_9365_02be671c59f7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package session

import (
	"errors"
	"strings"
	"sync"
	"testing"
	"time"

	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/fiber/v3/extractors"
	"github.com/gofiber/fiber/v3/internal/storage/memory"
	"github.com/google/uuid"
	"github.com/stretchr/testify/require"
	"github.com/valyala/fasthttp"
)

// go test -run Test_Session
func Test_Session(t *testing.T) {
	t.Parallel()

	// session store
	store := NewStore()

	// fiber instance
	app := fiber.New()

	// fiber context
	ctx := app.AcquireCtx(&fasthttp.RequestCtx{})

	// Get a new session
	sess, err := store.Get(ctx)
	require.NoError(t, err)
	require.True(t, sess.Fresh())
	token := sess.ID()
	require.NoError(t, sess.Save())

	sess.Release()
	app.ReleaseCtx(ctx)
	ctx = app.AcquireCtx(&fasthttp.RequestCtx{})

	// set session using default cookie extractor
	ctx.Request().Header.SetCookie("session_id", token)

	// get session
	sess, err = store.Get(ctx)
	require.NoError(t, err)
	require.False(t, sess.Fresh())

	// get keys
	keys := sess.Keys()
	require.Equal(t, []any{}, keys)

	// get value
	name := sess.Get("name")
	require.Nil(t, name)

	// set value
	sess.Set("name", "john")

// ... (1670 more lines)

Subdomains

Dependencies

  • errors

Frequently Asked Questions

What does session_test.go do?
session_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberMiddleware domain, Session subdomain.
What functions are defined in session_test.go?
session_test.go defines 25 function(s): Benchmark_Session, Benchmark_Session_Asserted, Benchmark_Session_Asserted_Parallel, Benchmark_Session_Parallel, Test_Session, Test_Session_CSRF_Scenario, Test_Session_ChainedExtractors, Test_Session_Concurrency, Test_Session_Cookie, Test_Session_Cookie_In_Middleware_Chain, and 15 more.
What does session_test.go depend on?
session_test.go imports 1 module(s): errors.
Where is session_test.go in the architecture?
session_test.go is located at middleware/session/session_test.go (domain: FiberMiddleware, subdomain: Session, directory: middleware/session).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free