-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmisc_test.go
More file actions
77 lines (67 loc) · 2.09 KB
/
misc_test.go
File metadata and controls
77 lines (67 loc) · 2.09 KB
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
package flowbase
import (
"os"
"path/filepath"
"reflect"
"sync"
"testing"
)
var initTestLogsLock sync.Mutex
// --------------------------------------------------------------------------------
// Testing Helper stuff
// --------------------------------------------------------------------------------
func initTestLogs() {
if Warning == nil {
//InitLogDebug()
InitLogWarning()
}
}
func cleanFiles(fileNames ...string) {
Debug.Println("Starting to remove files:", fileNames)
for _, fileName := range fileNames {
auditFileName := fileName + ".audit.json"
if _, err := os.Stat(fileName); err == nil {
errRem := os.Remove(fileName)
Check(errRem)
Debug.Println("Successfully removed file", fileName)
}
if _, err := os.Stat(auditFileName); err == nil {
errRem := os.Remove(auditFileName)
Check(errRem)
Debug.Println("Successfully removed audit.json file", auditFileName)
}
}
}
func cleanFilePatterns(filePatterns ...string) {
for _, pattern := range filePatterns {
if matches, err := filepath.Glob(pattern); err == nil {
for _, file := range matches {
if err := os.Remove(file); err != nil {
Failf("Could not remove file: %s\nError: %v\n", file, err)
}
}
} else {
Failf("Could not glob pattern: %s\nError: %v\n", pattern, err)
}
}
}
func assertIsType(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(reflect.TypeOf(expected), reflect.TypeOf(actual)) {
t.Errorf("Types do not match! (%s) and (%s)\n", reflect.TypeOf(expected).String(), reflect.TypeOf(actual).String())
}
}
func assertNil(t *testing.T, obj interface{}, msgs ...interface{}) {
if obj != nil {
t.Errorf("Object is not nil: %v. Message: %v\n", obj, msgs)
}
}
func assertNotNil(t *testing.T, obj interface{}, msgs ...interface{}) {
if obj == nil {
t.Errorf("Object is nil, which it should not be: %v. Message: %v\n", obj, msgs)
}
}
func assertEqualValues(t *testing.T, expected interface{}, actual interface{}, msgs ...interface{}) {
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Values are not equal (Expected: %v, Actual: %v)\n", expected, actual)
}
}