mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
context propagation: apic, unit tests (#3271)
* context propagation: apic * context propagation: unit tests
This commit is contained in:
parent
af3116d1a7
commit
06adbe031d
10 changed files with 189 additions and 179 deletions
|
@ -187,14 +187,14 @@ func TestLPMetrics(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
lapi := SetupLAPITest(t)
|
||||
lapi := SetupLAPITest(t, ctx)
|
||||
|
||||
dbClient, err := database.NewClient(context.Background(), lapi.DBConfig)
|
||||
dbClient, err := database.NewClient(ctx, lapi.DBConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create database client: %s", err)
|
||||
}
|
||||
|
||||
w := lapi.RecordResponse(t, http.MethodPost, "/v1/usage-metrics", strings.NewReader(tt.body), tt.authType)
|
||||
w := lapi.RecordResponse(t, ctx, http.MethodPost, "/v1/usage-metrics", strings.NewReader(tt.body), tt.authType)
|
||||
|
||||
assert.Equal(t, tt.expectedStatusCode, w.Code)
|
||||
assert.Contains(t, w.Body.String(), tt.expectedResponse)
|
||||
|
@ -359,14 +359,14 @@ func TestRCMetrics(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
lapi := SetupLAPITest(t)
|
||||
lapi := SetupLAPITest(t, ctx)
|
||||
|
||||
dbClient, err := database.NewClient(context.Background(), lapi.DBConfig)
|
||||
dbClient, err := database.NewClient(ctx, lapi.DBConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create database client: %s", err)
|
||||
}
|
||||
|
||||
w := lapi.RecordResponse(t, http.MethodPost, "/v1/usage-metrics", strings.NewReader(tt.body), tt.authType)
|
||||
w := lapi.RecordResponse(t, ctx, http.MethodPost, "/v1/usage-metrics", strings.NewReader(tt.body), tt.authType)
|
||||
|
||||
assert.Equal(t, tt.expectedStatusCode, w.Code)
|
||||
assert.Contains(t, w.Body.String(), tt.expectedResponse)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue