Home / Function/ Test_CopyContextToFiberContext() — fiber Function Reference

Test_CopyContextToFiberContext() — fiber Function Reference

Architecture documentation for the Test_CopyContextToFiberContext() function in adaptor_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  c1ef3c90_f845_89bc_5f9a_ab4c0a4a2604["Test_CopyContextToFiberContext()"]
  8ec96b38_44b4_af66_6f6f_dd60f87b680c["adaptor_test.go"]
  c1ef3c90_f845_89bc_5f9a_ab4c0a4a2604 -->|defined in| 8ec96b38_44b4_af66_6f6f_dd60f87b680c
  style c1ef3c90_f845_89bc_5f9a_ab4c0a4a2604 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/adaptor/adaptor_test.go lines 815–880

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

	t.Run("unsupported context type", func(t *testing.T) {
		t.Parallel()
		// Test with non-struct context (should return early)
		var fctx fasthttp.RequestCtx
		stringContext := "not a struct"

		// This should not panic and should handle the non-struct gracefully
		CopyContextToFiberContext(&stringContext, &fctx)
		// No assertions needed - just ensuring it doesn't panic
	})

	t.Run("context with unknown field", func(t *testing.T) {
		t.Parallel()
		// Test the default case (continue statement coverage)
		type customContext struct {
			UnknownField string
		}

		var fctx fasthttp.RequestCtx
		ctx := customContext{UnknownField: "test"}

		// This should hit the default case and continue
		CopyContextToFiberContext(&ctx, &fctx)
		// No assertions needed - just ensuring it doesn't panic and continues
	})

	t.Run("invalid src", func(t *testing.T) {
		var fctx fasthttp.RequestCtx
		CopyContextToFiberContext(nil, &fctx)
		// Add assertion to ensure no panic and coverage is detected
		assert.NotNil(t, &fctx)
	})

	t.Run("nil pointer", func(t *testing.T) {
		var nilPtr *context.Context // Nil pointer to a context
		var fctx fasthttp.RequestCtx
		CopyContextToFiberContext(nilPtr, &fctx)
		// Add assertion to ensure no panic and coverage is detected
		assert.NotNil(t, &fctx)
	})

	t.Run("multi-level pointer", func(t *testing.T) {
		t.Parallel()
		var fctx fasthttp.RequestCtx
		ctx := context.Background()
		ptr := &ctx
		doublePtr := &ptr
		// Test deref pointer chains
		CopyContextToFiberContext(doublePtr, &fctx)
		// No assertions needed - just ensuring it doesn't panic
	})

	t.Run("non-addressable struct", func(t *testing.T) {
		t.Parallel()
		var fctx fasthttp.RequestCtx
		type testStruct struct {
			Field string
		}
		// Pass struct value directly to test addressability check
		CopyContextToFiberContext(testStruct{Field: "test"}, &fctx)
		// No assertions needed - just ensuring it doesn't panic and creates temporary
	})
}

Domain

Subdomains

Frequently Asked Questions

What does Test_CopyContextToFiberContext() do?
Test_CopyContextToFiberContext() is a function in the fiber codebase, defined in middleware/adaptor/adaptor_test.go.
Where is Test_CopyContextToFiberContext() defined?
Test_CopyContextToFiberContext() is defined in middleware/adaptor/adaptor_test.go at line 815.

Analyze Your Own Codebase

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

Try Supermodel Free