aboutsummaryrefslogtreecommitdiff
path: root/internal/accept/accept_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-08-18 13:40:20 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-08-18 13:40:20 +0200
commita3ccdd9f491c20771cfda343ebebd4b5d0ea6602 (patch)
treef0ad530dd072c55c6f46dfea23af993fb31333d4 /internal/accept/accept_test.go
parent5d17264c8ab8042042162f3b968557aabc4976b3 (diff)
downloadgo-gg-a3ccdd9f491c20771cfda343ebebd4b5d0ea6602.tar.gz
test coverage for microprom
Diffstat (limited to 'internal/accept/accept_test.go')
-rw-r--r--internal/accept/accept_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/accept/accept_test.go b/internal/accept/accept_test.go
index 90b6934..edfef42 100644
--- a/internal/accept/accept_test.go
+++ b/internal/accept/accept_test.go
@@ -12,6 +12,7 @@ import (
)
func TestAcceptWithHeader(t *testing.T) {
+ // asking for a wide range of formats, including wildcard matches
h := accept.ParseHeader([]string{"text/*;q=0.3, text/plain;format=flowed, text/plain;format=fixed;q=0.4, */*;q=0.5"})
assert.Equal(t, h.Negotiate(
@@ -38,6 +39,18 @@ func TestAcceptWithHeader(t *testing.T) {
"text/markdown", // matches with q=0.3
"text/plain", // matches with q=0.3 (but first wins)
), Some("text/markdown"))
+
+ // asking for specific formats only
+ h = accept.ParseHeader([]string{"image/png, image/jpeg"})
+
+ assert.Equal(t, h.Negotiate(
+ "text/plain",
+ "image/png",
+ ), Some("image/png"))
+
+ assert.Equal(t, h.Negotiate(
+ "text/plain",
+ ), None[string]())
}
func TestAcceptWithoutHeader(t *testing.T) {