Home / Function/ Test_Extractor_Chain_AllErrors() — fiber Function Reference

Test_Extractor_Chain_AllErrors() — fiber Function Reference

Architecture documentation for the Test_Extractor_Chain_AllErrors() function in extractors_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  de071203_4701_3741_b663_6496d7b2e236["Test_Extractor_Chain_AllErrors()"]
  cf5e296e_8db5_6f84_b05a_9c0cac6f83e7["extractors_test.go"]
  de071203_4701_3741_b663_6496d7b2e236 -->|defined in| cf5e296e_8db5_6f84_b05a_9c0cac6f83e7
  style de071203_4701_3741_b663_6496d7b2e236 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

extractors/extractors_test.go lines 709–744

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

	app := fiber.New()

	// Test chain where all extractors return errors
	errorExtractor1 := Extractor{
		Extract: func(_ fiber.Ctx) (string, error) {
			return "", fiber.NewError(fiber.StatusUnauthorized, "First auth error")
		},
		Key:    "error1",
		Source: SourceCustom,
	}

	errorExtractor2 := Extractor{
		Extract: func(_ fiber.Ctx) (string, error) {
			return "", fiber.NewError(fiber.StatusForbidden, "Second auth error")
		},
		Key:    "error2",
		Source: SourceCustom,
	}

	chainExtractor := Chain(errorExtractor1, errorExtractor2)

	ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
	t.Cleanup(func() { app.ReleaseCtx(ctx) })

	token, err := chainExtractor.Extract(ctx)
	require.Empty(t, token)
	require.Error(t, err)
	require.Contains(t, err.Error(), "Second auth error") // Should return last error

	var fe *fiber.Error
	require.ErrorAs(t, err, &fe)
	require.Equal(t, fiber.StatusForbidden, fe.Code)
}

Domain

Subdomains

Frequently Asked Questions

What does Test_Extractor_Chain_AllErrors() do?
Test_Extractor_Chain_AllErrors() is a function in the fiber codebase, defined in extractors/extractors_test.go.
Where is Test_Extractor_Chain_AllErrors() defined?
Test_Extractor_Chain_AllErrors() is defined in extractors/extractors_test.go at line 709.

Analyze Your Own Codebase

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

Try Supermodel Free