forked from open-telemetry/opentelemetry-go-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.go
44 lines (39 loc) · 1.09 KB
/
options_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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package runtime // import "go.opentelemetry.io/contrib/instrumentation/runtime"
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNewConfig(t *testing.T) {
for _, tt := range []struct {
name string
opts []Option
expect config
}{
{
name: "default",
expect: config{MinimumReadMemStatsInterval: 15 * time.Second},
},
{
name: "negative MinimumReadMemStatsInterval ignored",
opts: []Option{WithMinimumReadMemStatsInterval(-1 * time.Second)},
expect: config{MinimumReadMemStatsInterval: 15 * time.Second},
},
{
name: "set MinimumReadMemStatsInterval",
opts: []Option{WithMinimumReadMemStatsInterval(10 * time.Second)},
expect: config{MinimumReadMemStatsInterval: 10 * time.Second},
},
} {
t.Run(tt.name, func(t *testing.T) {
got := newConfig(tt.opts...)
assert.True(t, configEqual(got, tt.expect))
})
}
}
func configEqual(a, b config) bool {
// ignore MeterProvider
return a.MinimumReadMemStatsInterval == b.MinimumReadMemStatsInterval
}