Home / Function/ TestData_ResetPreservesAllocation() — fiber Function Reference

TestData_ResetPreservesAllocation() — fiber Function Reference

Architecture documentation for the TestData_ResetPreservesAllocation() function in data_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  688dcdea_5419_99e6_2324_c0f481dc8084["TestData_ResetPreservesAllocation()"]
  31960edf_7060_281a_0b6d_40d015c11902["data_test.go"]
  688dcdea_5419_99e6_2324_c0f481dc8084 -->|defined in| 31960edf_7060_281a_0b6d_40d015c11902
  0c84548f_415c_aee4_0a3e_2e9a93e8e08a["lockedMapPointer()"]
  688dcdea_5419_99e6_2324_c0f481dc8084 -->|calls| 0c84548f_415c_aee4_0a3e_2e9a93e8e08a
  8ad2f861_e554_a9ce_02fd_d2d440536475["requireDataEmpty()"]
  688dcdea_5419_99e6_2324_c0f481dc8084 -->|calls| 8ad2f861_e554_a9ce_02fd_d2d440536475
  style 688dcdea_5419_99e6_2324_c0f481dc8084 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/session/data_test.go lines 209–232

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

	d := acquireData()
	d.Reset() // Ensure clean state from pool
	t.Cleanup(func() {
		d.Reset()
		dataPool.Put(d)
	})

	originalPtr := lockedMapPointer(d)

	d.Set("key1", "value1")
	d.Set("key2", "value2")
	require.Equal(t, originalPtr, lockedMapPointer(d), "Expected map pointer to stay constant after writes")

	d.Reset()
	requireDataEmpty(t, d, "Expected data map to be empty after reset")
	require.Equal(t, originalPtr, lockedMapPointer(d), "Expected reset to preserve underlying map")

	d.Set("key3", "value3")
	require.Nil(t, d.Get("key1"), "Expected cleared key not to leak after reset")
	require.Equal(t, originalPtr, lockedMapPointer(d), "Expected map pointer to remain stable after further writes")
}

Subdomains

Frequently Asked Questions

What does TestData_ResetPreservesAllocation() do?
TestData_ResetPreservesAllocation() is a function in the fiber codebase, defined in middleware/session/data_test.go.
Where is TestData_ResetPreservesAllocation() defined?
TestData_ResetPreservesAllocation() is defined in middleware/session/data_test.go at line 209.
What does TestData_ResetPreservesAllocation() call?
TestData_ResetPreservesAllocation() calls 2 function(s): lockedMapPointer, requireDataEmpty.

Analyze Your Own Codebase

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

Try Supermodel Free