-
Notifications
You must be signed in to change notification settings - Fork 39
/
propagation_internal_test.go
52 lines (47 loc) · 1.23 KB
/
propagation_internal_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
// (c) Copyright IBM Corp. 2021
// (c) Copyright Instana Inc. 2020
package instana
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestParseLevel(t *testing.T) {
examples := map[string]struct {
Value string
ExpectedSuppressed bool
ExpectedCorrelation EUMCorrelationData
}{
"empty header": {},
"level=0, no correlation id": {
Value: "0",
ExpectedSuppressed: true,
},
"level=1, no correlation id": {
Value: "1",
},
"level=0, with correlation id": {
Value: "0 , correlationType=web ;\t correlationId=Test Value",
ExpectedSuppressed: true,
ExpectedCorrelation: EUMCorrelationData{
Type: "web",
ID: "Test Value",
},
},
"level=1, with correlation id": {
Value: "1,correlationType=mobile;correlationId=Test Value",
ExpectedCorrelation: EUMCorrelationData{
Type: "mobile",
ID: "Test Value",
},
},
}
for name, example := range examples {
t.Run(name, func(t *testing.T) {
suppressed, corrData, err := parseLevel(example.Value)
require.NoError(t, err)
assert.Equal(t, example.ExpectedSuppressed, suppressed)
assert.Equal(t, example.ExpectedCorrelation, corrData)
})
}
}