(t *testing.T)
| 228 | } |
| 229 | |
| 230 | func TestBuildPathFromExpr(t *testing.T) { |
| 231 | cases := map[string]struct { |
| 232 | multipartRequest bool |
| 233 | deprecated bool |
| 234 | expected Operation |
| 235 | }{ |
| 236 | "multipart request": { |
| 237 | multipartRequest: true, |
| 238 | deprecated: false, |
| 239 | expected: Operation{ |
| 240 | Deprecated: false, |
| 241 | Consumes: []string{"multipart/form-data"}, |
| 242 | Parameters: []*Parameter{{In: "formData"}}, |
| 243 | }, |
| 244 | }, |
| 245 | "non multipart request": { |
| 246 | multipartRequest: false, |
| 247 | deprecated: true, |
| 248 | expected: Operation{ |
| 249 | Deprecated: true, |
| 250 | Consumes: nil, |
| 251 | Parameters: []*Parameter{{In: "body"}}, |
| 252 | }, |
| 253 | }, |
| 254 | } |
| 255 | for k, tc := range cases { |
| 256 | t.Run(k, func(t *testing.T) { |
| 257 | s := &V2{ |
| 258 | Consumes: []string{"application/json"}, |
| 259 | Paths: make(map[string]any), |
| 260 | } |
| 261 | root := &expr.RootExpr{ |
| 262 | API: &expr.APIExpr{ |
| 263 | HTTP: &expr.HTTPExpr{ |
| 264 | Path: "/", |
| 265 | }, |
| 266 | }, |
| 267 | } |
| 268 | expr.Root = root |
| 269 | h := &expr.HostExpr{} |
| 270 | route := &expr.RouteExpr{ |
| 271 | Method: "POST", |
| 272 | Endpoint: &expr.HTTPEndpointExpr{ |
| 273 | MethodExpr: &expr.MethodExpr{ |
| 274 | Payload: &expr.AttributeExpr{}, |
| 275 | }, |
| 276 | Service: &expr.HTTPServiceExpr{ |
| 277 | Root: root.API.HTTP, |
| 278 | ServiceExpr: &expr.ServiceExpr{}, |
| 279 | Paths: []string{"/foo"}, |
| 280 | Params: expr.NewEmptyMappedAttributeExpr(), |
| 281 | }, |
| 282 | Headers: expr.NewEmptyMappedAttributeExpr(), |
| 283 | Body: &expr.AttributeExpr{ |
| 284 | Type: expr.String, |
| 285 | }, |
| 286 | MultipartRequest: tc.multipartRequest, |
| 287 | Meta: expr.MetaExpr{}, |
nothing calls this directly
no test coverage detected