-
Notifications
You must be signed in to change notification settings - Fork 8
/
logging_params_test.go
62 lines (50 loc) · 1.27 KB
/
logging_params_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Copyright © 2024 Acronis International GmbH.
Released under MIT license.
*/
package middleware
import (
"testing"
"time"
"github.com/ssgreg/logf"
"github.com/stretchr/testify/require"
"github.com/acronis/go-appkit/log"
)
func TestLoggingParams_SetTimeSlotDurationMs(t *testing.T) {
lp := LoggingParams{}
lp.AddTimeSlotInt("slot1", 100)
lp.AddTimeSlotInt("slot2", 200)
lp.fields = append(lp.fields, log.Field{Key: "time_slots", Type: logf.FieldTypeObject, Any: lp.timeSlots})
expected := LoggingParams{
fields: []log.Field{
{
Key: "time_slots",
Type: logf.FieldTypeObject,
Any: loggableIntMap{
"slot1": 100,
"slot2": 200,
},
},
},
}
require.ElementsMatch(t, lp.fields, expected.fields)
}
func TestLoggingParams_SetTimeSlotDuration(t *testing.T) {
lp := LoggingParams{}
lp.AddTimeSlotDurationInMs("slot1", 1*time.Second)
lp.AddTimeSlotDurationInMs("slot2", 2*time.Second)
lp.fields = append(lp.fields, log.Field{Key: "time_slots", Type: logf.FieldTypeObject, Any: lp.timeSlots})
expected := LoggingParams{
fields: []log.Field{
{
Key: "time_slots",
Type: logf.FieldTypeObject,
Any: loggableIntMap{
"slot1": 1000,
"slot2": 2000,
},
},
},
}
require.ElementsMatch(t, lp.fields, expected.fields)
}