Test_Utils_AcceptsOfferType() — fiber Function Reference
Architecture documentation for the Test_Utils_AcceptsOfferType() function in helpers_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD c7b93f40_20a6_5314_64ee_fd1794b2dd7f["Test_Utils_AcceptsOfferType()"] c82e3595_b1b8_f596_c097_f26fa40159d1["helpers_test.go"] c7b93f40_20a6_5314_64ee_fd1794b2dd7f -->|defined in| c82e3595_b1b8_f596_c097_f26fa40159d1 style c7b93f40_20a6_5314_64ee_fd1794b2dd7f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
helpers_test.go lines 387–453
func Test_Utils_AcceptsOfferType(t *testing.T) {
t.Parallel()
testCases := []struct {
description string
spec string
specParams headerParams
offerType string
accepts bool
}{
{
description: "no params, matching",
spec: "application/json",
offerType: "application/json",
accepts: true,
},
{
description: "no params, mismatch",
spec: "application/json",
offerType: "application/xml",
accepts: false,
},
{
description: "mismatch with subtype prefix",
spec: "application/json",
offerType: "application/json+xml",
accepts: false,
},
{
description: "params match",
spec: "application/json",
specParams: headerParams{"format": []byte("foo"), "version": []byte("1")},
offerType: "application/json;version=1;format=foo;q=0.1",
accepts: true,
},
{
description: "spec has extra params",
spec: "text/html",
specParams: headerParams{"charset": []byte("utf-8")},
offerType: "text/html",
accepts: false,
},
{
description: "offer has extra params",
spec: "text/html",
offerType: "text/html;charset=utf-8",
accepts: true,
},
{
description: "ignores optional whitespace",
spec: "application/json",
specParams: headerParams{"format": []byte("foo"), "version": []byte("1")},
offerType: "application/json; version=1 ; format=foo ",
accepts: true,
},
{
description: "ignores optional whitespace",
spec: "application/json",
specParams: headerParams{"format": []byte("foo bar"), "version": []byte("1")},
offerType: `application/json;version="1";format="foo bar"`,
accepts: true,
},
}
for _, tc := range testCases {
accepts := acceptsOfferType(tc.spec, tc.offerType, tc.specParams)
require.Equal(t, tc.accepts, accepts, tc.description)
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Utils_AcceptsOfferType() do?
Test_Utils_AcceptsOfferType() is a function in the fiber codebase, defined in helpers_test.go.
Where is Test_Utils_AcceptsOfferType() defined?
Test_Utils_AcceptsOfferType() is defined in helpers_test.go at line 387.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free