Home / File/ manager_test.go — fiber Source File

manager_test.go — fiber Source File

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

File go FiberMiddleware Session 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  b7a3729c_8548_ab95_248a_c9152aa9b2d3["manager_test.go"]
  cc7104af_aece_1fe5_3985_791c7f34910c["context"]
  b7a3729c_8548_ab95_248a_c9152aa9b2d3 --> cc7104af_aece_1fe5_3985_791c7f34910c
  style b7a3729c_8548_ab95_248a_c9152aa9b2d3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package cache

import (
	"context"
	"testing"
	"time"

	"github.com/gofiber/utils/v2"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func Test_manager_get(t *testing.T) {
	t.Parallel()
	cacheManager := newManager(nil, true)
	t.Run("Item not found in cache", func(t *testing.T) {
		t.Parallel()
		it, err := cacheManager.get(context.Background(), utils.UUIDv4())
		require.ErrorIs(t, err, errCacheMiss)
		assert.Nil(t, it)
	})
	t.Run("Item found in cache", func(t *testing.T) {
		t.Parallel()
		id := utils.UUIDv4()
		cacheItem := cacheManager.acquire()
		cacheItem.body = []byte("test-body")
		require.NoError(t, cacheManager.set(context.Background(), id, cacheItem, 10*time.Second))
		it, err := cacheManager.get(context.Background(), id)
		require.NoError(t, err)
		assert.NotNil(t, it)
	})
}

func Test_manager_logKey(t *testing.T) {
	t.Parallel()

	redactedManager := newManager(nil, true)
	assert.Equal(t, redactedKey, redactedManager.logKey("secret"))

	plainManager := newManager(nil, false)
	assert.Equal(t, "secret", plainManager.logKey("secret"))
}

Subdomains

Dependencies

  • context

Frequently Asked Questions

What does manager_test.go do?
manager_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 manager_test.go?
manager_test.go defines 2 function(s): Test_manager_get, Test_manager_logKey.
What does manager_test.go depend on?
manager_test.go imports 1 module(s): context.
Where is manager_test.go in the architecture?
manager_test.go is located at middleware/cache/manager_test.go (domain: FiberMiddleware, subdomain: Session, directory: middleware/cache).

Analyze Your Own Codebase

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

Try Supermodel Free