-
Notifications
You must be signed in to change notification settings - Fork 1
/
caller_test.go
79 lines (60 loc) · 1.42 KB
/
caller_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
package logy
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCaller_Defined(t *testing.T) {
caller := Caller{
defined: true,
}
assert.True(t, caller.Defined())
caller = Caller{
defined: false,
}
assert.False(t, caller.Defined())
}
func TestCaller_NameShouldReturnEmptyStringIfItIsNotDefined(t *testing.T) {
caller := Caller{
defined: false,
}
assert.Empty(t, caller.Name())
}
func TestCaller_FileShouldReturnEmptyStringIfItIsNotDefined(t *testing.T) {
caller := Caller{
defined: false,
}
assert.Empty(t, caller.File())
}
func TestCaller_File(t *testing.T) {
caller := Caller{
defined: true,
file: "/Users/burakkoken/GolandProjects/slog/test/main.go",
}
assert.Equal(t, "main.go", caller.File())
}
func TestCaller_PathShouldReturnEmptyStringIfItIsNotDefined(t *testing.T) {
caller := Caller{
defined: false,
}
assert.Empty(t, caller.Path())
}
func TestCaller_Path(t *testing.T) {
caller := Caller{
defined: true,
file: "/Users/burakkoken/GolandProjects/slog/test/main.go",
}
assert.Equal(t, "/Users/burakkoken/GolandProjects/slog/test", caller.Path())
}
func TestCaller_PackageShouldReturnEmptyStringIfItIsNotDefined(t *testing.T) {
caller := Caller{
defined: false,
}
assert.Empty(t, caller.Package())
}
func TestCaller_Package(t *testing.T) {
caller := Caller{
defined: true,
function: "/test/any.main",
}
assert.Equal(t, "/test/any", caller.Package())
}