forked from open-telemetry/opentelemetry-ebpf-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
68 lines (58 loc) · 1.35 KB
/
main_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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Apache License 2.0.
* See the file "LICENSE" for details.
*/
package main
import (
"testing"
"github.com/elastic/otel-profiling-agent/config"
)
// tests expected to succeed
var tracersTestsOK = []struct {
in string
php bool
python bool
}{
{"all", true, true},
{"all,", true, true},
{"all,native", true, true},
{"native", false, false},
{"native,php", true, false},
{"native,python", false, true},
{"native,php,python", true, true},
}
// tests expected to fail
var tracersTestsFail = []struct {
in string
}{
{"NNative"},
{"foo"},
}
func TestParseTracers(t *testing.T) {
for _, tt := range tracersTestsOK {
tt := tt
in := tt.in
t.Run(tt.in, func(t *testing.T) {
include, err := parseTracers(in)
if err != nil {
t.Errorf("Unexpected error: %v", err)
return
}
if tt.php != include[config.PHPTracer] {
t.Errorf("Expected PHPTracer enabled by %s", in)
}
if tt.python != include[config.PythonTracer] {
t.Errorf("Expected PythonTracer enabled by %s", in)
}
})
}
for _, tt := range tracersTestsFail {
in := tt.in
t.Run(tt.in, func(t *testing.T) {
if _, err := parseTracers(in); err == nil {
t.Errorf("Unexpected success with '%s'", in)
}
})
}
}