mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-06-05 23:03:48 +00:00
Fixup govet
This commit is contained in:
+12
-16
@@ -282,23 +282,19 @@ func (suite *Tests) Test_parseGraphQLQuery() {
|
||||
suite.Run(tt.name, func() {
|
||||
cfg = &config{}
|
||||
parseConfig()
|
||||
ctx_headers := func() *fasthttp.RequestHeader {
|
||||
h := fasthttp.RequestHeader{}
|
||||
for k, v := range tt.suppliedQuery.headers {
|
||||
h.Add(k, v)
|
||||
}
|
||||
return &h
|
||||
}()
|
||||
|
||||
ctx_request := fasthttp.Request{
|
||||
Header: *ctx_headers,
|
||||
// Create a context first, then modify its request directly
|
||||
reqCtx := &fasthttp.RequestCtx{}
|
||||
|
||||
// Set headers directly on the request
|
||||
for k, v := range tt.suppliedQuery.headers {
|
||||
reqCtx.Request.Header.Add(k, v)
|
||||
}
|
||||
|
||||
ctx_request.AppendBody([]byte(tt.suppliedQuery.body))
|
||||
|
||||
ctx := suite.app.AcquireCtx(&fasthttp.RequestCtx{
|
||||
Request: ctx_request,
|
||||
})
|
||||
|
||||
// Set the body
|
||||
reqCtx.Request.AppendBody([]byte(tt.suppliedQuery.body))
|
||||
|
||||
// Now create the fiber context with the request context
|
||||
ctx := suite.app.AcquireCtx(reqCtx)
|
||||
|
||||
// defer func() {
|
||||
// cfg = &config{}
|
||||
|
||||
+14
-16
@@ -87,23 +87,21 @@ func (suite *Tests) Test_proxyTheRequest() {
|
||||
cfg.Server.HostGraphQLReadOnly = tt.hostRO
|
||||
}
|
||||
|
||||
ctx_headers := func() *fasthttp.RequestHeader {
|
||||
h := fasthttp.RequestHeader{}
|
||||
for k, v := range tt.headers {
|
||||
h.Add(k, v)
|
||||
}
|
||||
return &h
|
||||
}()
|
||||
|
||||
ctx_request := fasthttp.Request{
|
||||
Header: *ctx_headers,
|
||||
// Create a request context first
|
||||
reqCtx := &fasthttp.RequestCtx{}
|
||||
|
||||
// Set headers directly on the request
|
||||
for k, v := range tt.headers {
|
||||
reqCtx.Request.Header.Add(k, v)
|
||||
}
|
||||
ctx_request.SetBody([]byte(tt.body))
|
||||
ctx_request.SetRequestURI(tt.path)
|
||||
ctx_request.Header.SetMethod("POST")
|
||||
ctx := suite.app.AcquireCtx(&fasthttp.RequestCtx{
|
||||
Request: ctx_request,
|
||||
})
|
||||
|
||||
// Set the body and other request properties
|
||||
reqCtx.Request.SetBody([]byte(tt.body))
|
||||
reqCtx.Request.SetRequestURI(tt.path)
|
||||
reqCtx.Request.Header.SetMethod("POST")
|
||||
|
||||
// Create fiber context with the request context
|
||||
ctx := suite.app.AcquireCtx(reqCtx)
|
||||
res := parseGraphQLQuery(ctx)
|
||||
assert.NotNil(ctx, "Fiber context is nil", tt.name)
|
||||
err := proxyTheRequest(ctx, res.activeEndpoint)
|
||||
|
||||
Reference in New Issue
Block a user