This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
error_test.go
81 lines (72 loc) · 1.7 KB
/
error_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package newrelic
import (
"testing"
"github.com/newrelic/go-agent/v3/newrelic"
"github.com/stretchr/testify/require"
)
func TestError(t *testing.T) {
target1 := []string{"message:world", "class:foo", "attributes:bar"}
err := handleErr(target1)
require.Equal(t, newrelic.Error{
Message: "world",
Class: "foo",
Attributes: map[string]any{
"attributes": "bar",
},
Stack: nil,
}, err)
target2 := []string{"message:", "class:foo", "attributes:bar"}
err = handleErr(target2)
require.Equal(t, newrelic.Error{
Message: "",
Class: "foo",
Attributes: map[string]any{
"attributes": "bar",
},
Stack: nil,
}, err)
target3 := []string{"message:world", "class:", "attributes:bar"}
err = handleErr(target3)
require.Equal(t, newrelic.Error{
Message: "world",
Class: "",
Attributes: map[string]any{
"attributes": "bar",
},
Stack: nil,
}, err)
target4 := []string{"message:world", "class:foo", ""}
err = handleErr(target4)
require.Equal(t, newrelic.Error{
Message: "world",
Class: "foo",
Attributes: nil,
Stack: nil,
}, err)
target5 := []string{":", ":", ":"}
err = handleErr(target5)
require.Equal(t, newrelic.Error{
Message: "",
Class: "",
Attributes: nil,
Stack: nil,
}, err)
target6 := []string{": ", " :", ": "}
err = handleErr(target6)
require.Equal(t, newrelic.Error{
Message: "",
Class: "",
Attributes: nil,
Stack: nil,
}, err)
target7 := []string{"message:что", "class:это", "attributes:за язык"}
err = handleErr(target7)
require.Equal(t, newrelic.Error{
Message: "что",
Class: "это",
Attributes: map[string]any{
"attributes": "за язык",
},
Stack: nil,
}, err)
}