-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
45 lines (34 loc) · 1.29 KB
/
config_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
package profiler
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestConfig(t *testing.T) {
t.Setenv("PLATFORM_APPLICATION_NAME", "foo2")
t.Setenv("BLACKFIRE_CONPROF_APP_NAME", "foo")
t.Setenv("PLATFORM_PROJECT", "43")
config, err := initDefaultConfig()
require.Nil(t, err)
require.Contains(t, config.labels, "runtime")
require.Contains(t, config.labels, "runtime_os")
require.Contains(t, config.labels, "runtime_arch")
require.Contains(t, config.labels, "runtime_version")
require.Contains(t, config.labels, "host")
require.Contains(t, config.labels, "application_name")
require.Contains(t, config.labels, "project_id")
require.NotContains(t, config.labels, "user_id")
require.Equal(t, "go", config.labels["runtime"])
require.Equal(t, "foo", config.labels["application_name"])
require.Equal(t, "43", config.labels["project_id"])
WithLabels(map[string]string{
"user_id": "37",
"application_name": "bar",
})(config)
require.Contains(t, config.labels, "user_id")
require.Equal(t, "37", config.labels["user_id"])
require.Equal(t, "bar", config.labels["application_name"])
require.Equal(t, "go", config.labels["runtime"])
WithAppName("duh!")(config)
require.Equal(t, "duh!", config.labels["application_name"])
require.Equal(t, "go", config.labels["runtime"])
}