Skip to content

Commit 5789fae

Browse files
jairajcJai Raj Choudhary
andauthored
fix: resolve database connection leak issue in ORM extension (#827)
* ix: resolve database connection leak issue in ORM extension --------- Co-authored-by: Jai Raj Choudhary <[email protected]>
1 parent 1d95342 commit 5789fae

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

cmd/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
402402
default:
403403
o.limiter.Accept()
404404

405-
ctxWithTimeout, _ := context.WithTimeout(ctx, o.requestTimeout)
405+
ctxWithTimeout, cancel := context.WithTimeout(ctx, o.requestTimeout)
406+
defer cancel() // Ensure context is always cancelled when leaving this scope
406407
ctxWithTimeout = context.WithValue(ctxWithTimeout, runner.ContextKey("").ParentDir(), loader.GetContext())
407408

408409
output, err = suiteRunner.RunTestCase(&testCase, dataContext, ctxWithTimeout)

pkg/mock/types.go

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,65 @@ limitations under the License.
1616
package mock
1717

1818
type Object struct {
19-
Name string `yaml:"name" json:"name"`
20-
InitCount *int `yaml:"initCount" json:"initCount"`
21-
Sample string `yaml:"sample" json:"sample"`
19+
Name string `yaml:"name" json:"name"`
20+
InitCount *int `yaml:"initCount" json:"initCount"`
21+
Sample string `yaml:"sample" json:"sample"`
2222
}
2323

2424
type Item struct {
25-
Name string `yaml:"name" json:"name"`
26-
Request Request `yaml:"request" json:"request"`
27-
Response Response `yaml:"response" json:"response"`
28-
Param map[string]interface{}
25+
Name string `yaml:"name" json:"name"`
26+
Request Request `yaml:"request" json:"request"`
27+
Response Response `yaml:"response" json:"response"`
28+
Param map[string]interface{}
2929
}
3030

3131
type Request struct {
32-
Protocol string `yaml:"protocol" json:"protocol"`
33-
Path string `yaml:"path" json:"path"`
34-
Method string `yaml:"method" json:"method"`
35-
Header map[string]string `yaml:"header" json:"header"`
36-
Body string `yaml:"body" json:"body"`
32+
Protocol string `yaml:"protocol" json:"protocol"`
33+
Path string `yaml:"path" json:"path"`
34+
Method string `yaml:"method" json:"method"`
35+
Header map[string]string `yaml:"header" json:"header"`
36+
Body string `yaml:"body" json:"body"`
3737
}
3838

3939
type RequestWithAuth struct {
40-
Request `yaml:",inline"`
41-
BearerAPI string `yaml:"bearerAPI" json:"bearerAPI"`
42-
Username string `yaml:"username" json:"username"`
43-
Password string `yaml:"password" json:"password"`
40+
Request `yaml:",inline"`
41+
BearerAPI string `yaml:"bearerAPI" json:"bearerAPI"`
42+
Username string `yaml:"username" json:"username"`
43+
Password string `yaml:"password" json:"password"`
4444
}
4545

4646
type Response struct {
47-
Encoder string `yaml:"encoder" json:"encoder"`
48-
Body string `yaml:"body" json:"body"`
49-
BodyFromFile string `yaml:"bodyFromFile" json:"bodyFromFile"`
50-
Header map[string]string `yaml:"header" json:"header"`
51-
StatusCode int `yaml:"statusCode" json:"statusCode"`
52-
BodyData []byte
47+
Encoder string `yaml:"encoder" json:"encoder"`
48+
Body string `yaml:"body" json:"body"`
49+
BodyFromFile string `yaml:"bodyFromFile" json:"bodyFromFile"`
50+
Header map[string]string `yaml:"header" json:"header"`
51+
StatusCode int `yaml:"statusCode" json:"statusCode"`
52+
BodyData []byte
5353
}
5454

5555
type Webhook struct {
56-
Name string `yaml:"name" json:"name"`
57-
Timer string `yaml:"timer" json:"timer"`
58-
Param map[string]string `yaml:"param" json:"param"`
59-
Request RequestWithAuth `yaml:"request" json:"request"`
56+
Name string `yaml:"name" json:"name"`
57+
Timer string `yaml:"timer" json:"timer"`
58+
Param map[string]string `yaml:"param" json:"param"`
59+
Request RequestWithAuth `yaml:"request" json:"request"`
6060
}
6161

6262
type Proxy struct {
63-
Prefix string `yaml:"prefix" json:"prefix"`
64-
Port int `yaml:"port" json:"port"`
65-
Path string `yaml:"path" json:"path"`
66-
Target string `yaml:"target" json:"target"`
67-
RequestAmend RequestAmend `yaml:"requestAmend" json:"requestAmend"`
68-
Protocol string `yaml:"protocol" json:"protocol"`
63+
Prefix string `yaml:"prefix" json:"prefix"`
64+
Port int `yaml:"port" json:"port"`
65+
Path string `yaml:"path" json:"path"`
66+
Target string `yaml:"target" json:"target"`
67+
RequestAmend RequestAmend `yaml:"requestAmend" json:"requestAmend"`
68+
Protocol string `yaml:"protocol" json:"protocol"`
6969
}
7070

7171
type RequestAmend struct {
72-
BodyPatch string `yaml:"bodyPatch" json:"bodyPatch"`
72+
BodyPatch string `yaml:"bodyPatch" json:"bodyPatch"`
7373
}
7474

7575
type Server struct {
76-
Objects []Object `yaml:"objects" json:"objects"`
77-
Items []Item `yaml:"items" json:"items"`
78-
Proxies []Proxy `yaml:"proxies" json:"proxies"`
79-
Webhooks []Webhook `yaml:"webhooks" json:"webhooks"`
76+
Objects []Object `yaml:"objects" json:"objects"`
77+
Items []Item `yaml:"items" json:"items"`
78+
Proxies []Proxy `yaml:"proxies" json:"proxies"`
79+
Webhooks []Webhook `yaml:"webhooks" json:"webhooks"`
8080
}

0 commit comments

Comments
 (0)