MCPcopy Create free account
hub / github.com/QuantumNous/new-api / newPluginProtocolTestContext

Function newPluginProtocolTestContext

controller/plugin_protocol_test.go:1456–1483  ·  view source on GitHub ↗
(stream, requestBodyStream bool)

Source from the content-addressed store, hash-verified

1454}
1455
1456func newPluginProtocolTestContext(stream, requestBodyStream bool) (*gin.Context, *httptest.ResponseRecorder) {
1457 recorder := httptest.NewRecorder()
1458 c, _ := gin.CreateTestContext(recorder)
1459 c.Request = httptest.NewRequest(http.MethodPost, "/v1/responses", strings.NewReader(`{}`))
1460 common.SetContextKey(c, constant.ContextKeyUserId, 71)
1461 common.SetContextKey(c, constant.ContextKeyTokenId, 81)
1462 common.SetContextKey(c, constant.ContextKeyUsingGroup, "default")
1463 c.Set("resolved_task_model", "video-model")
1464 c.Set(pluginruntime.ContextKeyProtocolRequest, pluginruntime.ProtocolRequestContext{
1465 RouteRequestContext: pluginruntime.RouteRequestContext{
1466 Path: "/v1/responses",
1467 Method: http.MethodPost,
1468 Params: map[string]string{},
1469 Query: map[string][]string{},
1470 Body: map[string]any{
1471 "kind": "json",
1472 "value": map[string]any{"model": "video-model", "stream": requestBodyStream},
1473 },
1474 RequestBody: map[string]any{
1475 "model": "video-model",
1476 "stream": requestBodyStream,
1477 },
1478 },
1479 Protocol: "openai_responses",
1480 Stream: stream,
1481 })
1482 return c, recorder
1483}
1484
1485func pluginProtocolTestDeps() pluginProtocolBridgeDeps {
1486 return pluginProtocolBridgeDeps{

Calls 2

SetMethod · 0.80
NewReaderMethod · 0.65

Tested by

no test coverage detected