-
Notifications
You must be signed in to change notification settings - Fork 17
/
main_init_test.go
73 lines (65 loc) · 1.35 KB
/
main_init_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
package main
import (
"reflect"
"testing"
"github.com/Ptt-official-app/go-pttbbsweb/types"
)
func Test_initAllConfig(t *testing.T) {
setupTest()
defer teardownTest()
type args struct {
filename string
}
tests := []struct {
name string
args args
wantErr bool
wantHTTP_POST string
}{
// TODO: Add test cases.
{
args: args{"testcase/test.ini"},
wantHTTP_POST: "test.dev",
},
{
args: args{"testcase/non-exists.ini"},
wantErr: true,
},
{
args: args{"testcase/non-exists"},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := initAllConfig(tt.args.filename)
if (err != nil) != tt.wantErr {
t.Errorf("initConfig() error = %v, wantErr %v", err, tt.wantErr)
}
if err != nil {
return
}
if !reflect.DeepEqual(types.HTTP_HOST, tt.wantHTTP_POST) {
t.Errorf("initConfig() HTTP_HOST: %v want :%v", types.HTTP_HOST, tt.wantHTTP_POST)
}
})
}
}
func Test_initMain(t *testing.T) {
setupTest()
defer teardownTest()
tests := []struct {
name string
wantErr bool
}{
// TODO: Add test cases.
{wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := initMain(); (err != nil) != tt.wantErr {
t.Errorf("initMain() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}