1
1
package test_helpers
2
2
3
3
import (
4
+ "fmt"
4
5
"testing"
5
6
"time"
6
7
@@ -75,7 +76,8 @@ func SkipIfSQLUnsupported(t testing.TB) {
75
76
}
76
77
}
77
78
78
- func skipIfLess (t * testing.T , feature string , major , minor , patch uint64 ) {
79
+ // SkipIfLess skips test run if Tarantool version is less than expected.
80
+ func SkipIfLess (t * testing.T , reason string , major , minor , patch uint64 ) {
79
81
t .Helper ()
80
82
81
83
isLess , err := IsTarantoolVersionLess (major , minor , patch )
@@ -84,11 +86,13 @@ func skipIfLess(t *testing.T, feature string, major, minor, patch uint64) {
84
86
}
85
87
86
88
if isLess {
87
- t .Skipf ("Skipping test for Tarantool without %s support " , feature )
89
+ t .Skipf ("Skipping test for Tarantool %s " , reason )
88
90
}
89
91
}
90
92
91
- func skipIfGreaterOrEqual (t * testing.T , feature string , major , minor , patch uint64 ) {
93
+ // SkipIfGreaterOrEqual skips test run if Tarantool version is greater or equal
94
+ // than expected.
95
+ func SkipIfGreaterOrEqual (t * testing.T , reason string , major , minor , patch uint64 ) {
92
96
t .Helper ()
93
97
94
98
isLess , err := IsTarantoolVersionLess (major , minor , patch )
@@ -97,40 +101,64 @@ func skipIfGreaterOrEqual(t *testing.T, feature string, major, minor, patch uint
97
101
}
98
102
99
103
if ! isLess {
100
- t .Skipf ("Skipping test for Tarantool with %s support " , feature )
104
+ t .Skipf ("Skipping test for Tarantool %s " , reason )
101
105
}
102
106
}
103
107
108
+ // SkipIfFeatureUnsupported skips test run if Tarantool does not yet support a feature.
109
+ func SkipIfFeatureUnsupported (t * testing.T , feature string , major , minor , patch uint64 ) {
110
+ t .Helper ()
111
+
112
+ SkipIfLess (t , fmt .Sprintf ("without %s support" , feature ), major , minor , patch )
113
+ }
114
+
115
+ // SkipIfFeatureSupported skips test run if Tarantool supports a feature.
116
+ // Helper if useful when we want to test if everything is alright
117
+ // on older versions.
118
+ func SkipIfFeatureSupported (t * testing.T , feature string , major , minor , patch uint64 ) {
119
+ t .Helper ()
120
+
121
+ SkipIfGreaterOrEqual (t , fmt .Sprintf ("with %s support" , feature ), major , minor , patch )
122
+ }
123
+
124
+ // SkipIfFeatureDropped skips test run if Tarantool had dropped
125
+ // support of a feature.
126
+ func SkipIfFeatureDropped (t * testing.T , feature string , major , minor , patch uint64 ) {
127
+ t .Helper ()
128
+
129
+ SkipIfGreaterOrEqual (t , fmt .Sprintf ("with %s support dropped" , feature ), major , minor , patch )
130
+ }
131
+
104
132
// SkipOfStreamsUnsupported skips test run if Tarantool without streams
105
133
// support is used.
106
134
func SkipIfStreamsUnsupported (t * testing.T ) {
107
135
t .Helper ()
108
136
109
- skipIfLess (t , "streams" , 2 , 10 , 0 )
137
+ SkipIfFeatureUnsupported (t , "streams" , 2 , 10 , 0 )
110
138
}
111
139
112
140
// SkipOfStreamsUnsupported skips test run if Tarantool without watchers
113
141
// support is used.
114
142
func SkipIfWatchersUnsupported (t * testing.T ) {
115
143
t .Helper ()
116
144
117
- skipIfLess (t , "watchers" , 2 , 10 , 0 )
145
+ SkipIfFeatureUnsupported (t , "watchers" , 2 , 10 , 0 )
118
146
}
119
147
120
148
// SkipIfWatchersSupported skips test run if Tarantool with watchers
121
149
// support is used.
122
150
func SkipIfWatchersSupported (t * testing.T ) {
123
151
t .Helper ()
124
152
125
- skipIfGreaterOrEqual (t , "watchers" , 2 , 10 , 0 )
153
+ SkipIfFeatureSupported (t , "watchers" , 2 , 10 , 0 )
126
154
}
127
155
128
156
// SkipIfIdUnsupported skips test run if Tarantool without
129
157
// IPROTO_ID support is used.
130
158
func SkipIfIdUnsupported (t * testing.T ) {
131
159
t .Helper ()
132
160
133
- skipIfLess (t , "id requests" , 2 , 10 , 0 )
161
+ SkipIfFeatureUnsupported (t , "id requests" , 2 , 10 , 0 )
134
162
}
135
163
136
164
// SkipIfIdSupported skips test run if Tarantool with
@@ -139,23 +167,23 @@ func SkipIfIdUnsupported(t *testing.T) {
139
167
func SkipIfIdSupported (t * testing.T ) {
140
168
t .Helper ()
141
169
142
- skipIfGreaterOrEqual (t , "id requests" , 2 , 10 , 0 )
170
+ SkipIfFeatureSupported (t , "id requests" , 2 , 10 , 0 )
143
171
}
144
172
145
173
// SkipIfErrorExtendedInfoUnsupported skips test run if Tarantool without
146
174
// IPROTO_ERROR (0x52) support is used.
147
175
func SkipIfErrorExtendedInfoUnsupported (t * testing.T ) {
148
176
t .Helper ()
149
177
150
- skipIfLess (t , "error extended info" , 2 , 4 , 1 )
178
+ SkipIfFeatureUnsupported (t , "error extended info" , 2 , 4 , 1 )
151
179
}
152
180
153
181
// SkipIfErrorMessagePackTypeUnsupported skips test run if Tarantool without
154
182
// MP_ERROR type over iproto support is used.
155
183
func SkipIfErrorMessagePackTypeUnsupported (t * testing.T ) {
156
184
t .Helper ()
157
185
158
- skipIfLess (t , "error type in MessagePack" , 2 , 10 , 0 )
186
+ SkipIfFeatureUnsupported (t , "error type in MessagePack" , 2 , 10 , 0 )
159
187
}
160
188
161
189
// CheckEqualBoxErrors checks equivalence of tarantool.BoxError objects.
0 commit comments