/
SkipFunctions_test.go
66 lines (52 loc) · 1.72 KB
/
SkipFunctions_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
package ulog
import (
"testing"
)
func TestAddSkipFunctions(t *testing.T) {
setup(LEVEL_TRACE)
before := len(SkipFunctions())
AddSkipFunctions("a", "b", "c")
after := len(SkipFunctions())
if after-before != 3 {
t.Fatalf("did not add a,b,c correctly (before:%d after:%d)", before, after)
}
before = len(SkipFunctions())
AddSkipFunctions("a")
after = len(SkipFunctions())
if after-before != 0 {
t.Fatalf("did not add a,b,c correctly (before:%d after:%d)", before, after)
}
before = len(SkipFunctions())
AddSkipFunctions("b")
after = len(SkipFunctions())
if after-before != 0 {
t.Fatalf("did not add a,b,c correctly (before:%d after:%d)", before, after)
}
before = len(SkipFunctions())
AddSkipFunctions("c")
after = len(SkipFunctions())
if after-before != 0 {
t.Fatalf("did not add a,b,c correctly (before:%d after:%d)", before, after)
}
before = len(SkipFunctions())
AddSkipFunctions("a", "b", "c")
after = len(SkipFunctions())
if after-before != 0 {
t.Fatalf("did not add a,b,c correctly (before:%d after:%d)", before, after)
}
}
func TestSkipFunctions(t *testing.T) {
buffer := setup(LEVEL_TRACE)
// Skip this function -> log should tell us testing.tRunner is the logging entity
AddSkipFunctions("github.com/dunv/ulog.TestSkipFunctions")
// Replacing is tested separately and is usable here (this way we do not need to pay attention if the line of code or the file of the testing std-lib changes)
AddReplaceFunction("testing.tRunner", "replacedRunner")
Trace("halloWelt")
checkCustomFunction(buffer, _LEVEL_TRACE, "halloWelt", "replacedRunner", t)
}
func TestGetSkipFunctions(t *testing.T) {
fns := SkipFunctions()
if len(fns) != len(skipFunctions) {
t.Errorf("could not retrieve skipFunctions")
}
}