-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacc_test.go
55 lines (48 loc) · 966 Bytes
/
acc_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
package main
import (
"fmt"
"testing"
"github.com/bon-ami/eztools"
)
func TestGetUsr(t *testing.T) {
logger, db := prepareEnv()
if logger != nil {
defer logger.Close()
}
var (
idE, idF int
errE, errF error
output string
)
//sub test env
if db != nil {
defer db.Close()
idE, errE = getUsrFromEnv(db)
}
//sub test cfg file
idF, output, errF = parseUsrFromFile(func(buf,
id string) (output string, breaking bool) {
return "matched", true
}, func(buf, id string) (output string, breaking bool) {
return
}, 0)
if errE != nil || errF != nil {
fmt.Println(errE)
fmt.Println(errF)
t.Fail()
}
if db != nil {
dispRes(t, "from env.", idE, output)
}
dispRes(t, "from cfg.", idF, output)
}
func dispRes(t *testing.T, from string, id int, output string) {
switch id {
case 0:
t.Error(from + " NO ID")
case eztools.InvalidID:
t.Error(from + " Invalid ID")
default:
fmt.Println(from+" ID ", id, " ", output)
}
}