-
Notifications
You must be signed in to change notification settings - Fork 0
/
suite.go
106 lines (92 loc) · 2.82 KB
/
suite.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Package comodo is a wrapper over github.com/stretchr/testify/suite aimed to make it's use easier and comfortable
package comodo
import (
"github.com/stretchr/testify/suite"
)
// Suite is wrapper over suite.Suite with some addon methods
type Suite struct {
suite.Suite
}
func (s *Suite) fail() {
s.Suite.T().FailNow()
}
// Fatalf is equivalent to Logf followed by FailNow.
func (s *Suite) Fatalf(msg string, args ...interface{}) {
s.T().Fatalf(msg, args...)
}
// Fatal is equivalent to Log followed by FailNow.
func (s *Suite) Fatal(args ...interface{}) {
s.T().Fatal(args...)
}
// NotEqualFail is equivalent to NotEqual followed by FailNow if assert fails.
func (s *Suite) NotEqualFail(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
var notEqual = s.Suite.NotEqual(expected, actual, msgAndArgs...)
if !notEqual {
s.fail()
}
return notEqual
}
// EqualFail is equivalent to Equal followed by FailNow if assert fails.
func (s *Suite) EqualFail(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
var equal = s.Suite.Equal(expected, actual, msgAndArgs...)
if !equal {
s.fail()
}
return equal
}
// NoErrorFail is equivalent to NoError followed by FailNow if assert fails.
func (s *Suite) NoErrorFail(err error, msgAndArgs ...interface{}) bool {
var noError = s.Suite.NoError(err, msgAndArgs...)
if !noError {
s.fail()
}
return noError
}
// TrueFail is equivalent to True followed by FailNow if assert fails
func (s *Suite) TrueFail(value bool, msgAndArgs ...interface{}) bool {
var trueA = s.Suite.True(value, msgAndArgs...)
if !trueA {
s.fail()
}
return trueA
}
// FalseFail is equivalent to False followed by FailNow if assert fails
func (s *Suite) FalseFail(value bool, msgAndArgs ...interface{}) bool {
var falseA = s.Suite.False(value, msgAndArgs...)
if !falseA {
s.fail()
}
return falseA
}
// NotNilFail is equivalent to NotNil followed by FailNow if assert fails
func (s *Suite) NotNilFail(value interface{}, msgAndArgs ...interface{}) bool {
var notNil = s.Suite.NotNil(value, msgAndArgs...)
if !notNil {
s.fail()
}
return notNil
}
// NilFail is equivalent to Nil followed by FailNow if assert fails
func (s *Suite) NilFail(value interface{}, msgAndArgs ...interface{}) bool {
var isNil = s.Suite.Nil(value, msgAndArgs...)
if !isNil {
s.fail()
}
return isNil
}
// EmptyFail is equivalent to Empty followed by FailNow if assert fails
func (s *Suite) EmptyFail(object interface{}, msgAndArgs ...interface{}) bool {
var empty = s.Suite.Empty(object, msgAndArgs...)
if !empty {
s.fail()
}
return empty
}
// NotEmptyFail is equivalent to NotEmpty followed by FailNow if assert fails
func (s *Suite) NotEmptyFail(object interface{}, msgAndArgs ...interface{}) bool {
var notEmpty = s.Suite.NotEmpty(object, msgAndArgs...)
if !notEmpty {
s.fail()
}
return notEmpty
}