-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsampler_test.go
41 lines (36 loc) · 1013 Bytes
/
sampler_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
// SPDX-FileCopyrightText: 2023-present Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
package dazl
import (
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"testing"
)
func TestUnmarshalSampler(t *testing.T) {
text := `
basic:
interval: 10
maxLevel: info
`
config := &samplingConfig{}
assert.NoError(t, yaml.Unmarshal([]byte(text), config))
assert.NotNil(t, config.Basic)
assert.Nil(t, config.Random)
assert.Equal(t, 10, config.Basic.Interval)
assert.Equal(t, InfoLevel, config.Basic.MaxLevel.Level())
text = "random"
config = &samplingConfig{}
assert.NoError(t, yaml.Unmarshal([]byte(text), config))
assert.Nil(t, config.Basic)
assert.NotNil(t, config.Random)
assert.Equal(t, EmptyLevel, config.Random.MaxLevel.Level())
text = `
random:
maxLevel: info`
config = &samplingConfig{}
assert.NoError(t, yaml.Unmarshal([]byte(text), config))
assert.Nil(t, config.Basic)
assert.NotNil(t, config.Random)
assert.Equal(t, InfoLevel, config.Random.MaxLevel.Level())
}