@@ -110,6 +110,30 @@ func TestCarParams(t *testing.T) {
110
110
require .Equal (t , test .expectedDuplicates .String (), params .Duplicates .String ())
111
111
}
112
112
})
113
+
114
+ t .Run ("buildCarParams from Accept header: order and dups parsing (invalid)" , func (t * testing.T ) {
115
+ t .Parallel ()
116
+
117
+ // below ensure the implicit default (DFS and no duplicates) is correctly inferred
118
+ // from the value read from Accept header
119
+ tests := []string {
120
+ "application/vnd.ipld.car; dups=invalid" ,
121
+ "application/vnd.ipld.car; order=invalid" ,
122
+ "application/vnd.ipld.car; order=dfs; dups=invalid" ,
123
+ "application/vnd.ipld.car; order=invalid; dups=y" ,
124
+ }
125
+ for _ , test := range tests {
126
+ r := mustNewRequest (t , http .MethodGet , "http://example.com/" , nil )
127
+ r .Header .Set ("Accept" , test )
128
+
129
+ mediaType , formatParams , err := customResponseFormat (r )
130
+ assert .NoError (t , err )
131
+ assert .Equal (t , carResponseFormat , mediaType )
132
+
133
+ _ , err = buildCarParams (r , formatParams )
134
+ assert .ErrorContains (t , err , "unsupported application/vnd.ipld.car content type" )
135
+ }
136
+ })
113
137
}
114
138
115
139
func TestContentTypeFromCarParams (t * testing.T ) {
0 commit comments