-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
lambda_test.go
60 lines (54 loc) · 1.18 KB
/
lambda_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
package tracer_test
import (
"testing"
"github.com/fujiwara/tracer"
)
func TestExtractClusterName(t *testing.T) {
cases := []struct {
input string
expected string
}{
{
input: "arn:aws:ecs:ap-northeast-1:012345678901:cluster/main",
expected: "main",
},
{
input: "main",
expected: "main",
},
}
for _, c := range cases {
t.Run(c.input, func(t *testing.T) {
actual := tracer.ExtractClusterName(c.input)
if c.expected != actual {
t.Errorf("expected: %s, actual: %s", c.expected, actual)
}
})
}
}
func TestExtractTaskID(t *testing.T) {
cases := []struct {
input string
cluster string
expected string
}{
{
input: "0123456789abcdef0123456789abcdef",
cluster: "main",
expected: "0123456789abcdef0123456789abcdef",
},
{
input: "arn:aws:ecs:ap-northeast-1:012345678901:task/main/0123456789abcdef0123456789abcdef",
cluster: "main",
expected: "0123456789abcdef0123456789abcdef",
},
}
for _, c := range cases {
t.Run(c.input, func(t *testing.T) {
actual := tracer.ExtractTaskID(c.cluster, c.input)
if c.expected != actual {
t.Errorf("expected: %s, actual: %s", c.expected, actual)
}
})
}
}