11package test_helpers
22
33import (
4+ "fmt"
45 "testing"
56 "time"
67
@@ -75,7 +76,8 @@ func SkipIfSQLUnsupported(t testing.TB) {
7576 }
7677}
7778
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 ) {
7981 t .Helper ()
8082
8183 isLess , err := IsTarantoolVersionLess (major , minor , patch )
@@ -84,11 +86,13 @@ func skipIfLess(t *testing.T, feature string, major, minor, patch uint64) {
8486 }
8587
8688 if isLess {
87- t .Skipf ("Skipping test for Tarantool without %s support " , feature )
89+ t .Skipf ("Skipping test for Tarantool %s " , reason )
8890 }
8991}
9092
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 ) {
9296 t .Helper ()
9397
9498 isLess , err := IsTarantoolVersionLess (major , minor , patch )
@@ -97,40 +101,64 @@ func skipIfGreaterOrEqual(t *testing.T, feature string, major, minor, patch uint
97101 }
98102
99103 if ! isLess {
100- t .Skipf ("Skipping test for Tarantool with %s support " , feature )
104+ t .Skipf ("Skipping test for Tarantool %s " , reason )
101105 }
102106}
103107
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+
104132// SkipOfStreamsUnsupported skips test run if Tarantool without streams
105133// support is used.
106134func SkipIfStreamsUnsupported (t * testing.T ) {
107135 t .Helper ()
108136
109- skipIfLess (t , "streams" , 2 , 10 , 0 )
137+ SkipIfFeatureUnsupported (t , "streams" , 2 , 10 , 0 )
110138}
111139
112140// SkipOfStreamsUnsupported skips test run if Tarantool without watchers
113141// support is used.
114142func SkipIfWatchersUnsupported (t * testing.T ) {
115143 t .Helper ()
116144
117- skipIfLess (t , "watchers" , 2 , 10 , 0 )
145+ SkipIfFeatureUnsupported (t , "watchers" , 2 , 10 , 0 )
118146}
119147
120148// SkipIfWatchersSupported skips test run if Tarantool with watchers
121149// support is used.
122150func SkipIfWatchersSupported (t * testing.T ) {
123151 t .Helper ()
124152
125- skipIfGreaterOrEqual (t , "watchers" , 2 , 10 , 0 )
153+ SkipIfFeatureSupported (t , "watchers" , 2 , 10 , 0 )
126154}
127155
128156// SkipIfIdUnsupported skips test run if Tarantool without
129157// IPROTO_ID support is used.
130158func SkipIfIdUnsupported (t * testing.T ) {
131159 t .Helper ()
132160
133- skipIfLess (t , "id requests" , 2 , 10 , 0 )
161+ SkipIfFeatureUnsupported (t , "id requests" , 2 , 10 , 0 )
134162}
135163
136164// SkipIfIdSupported skips test run if Tarantool with
@@ -139,23 +167,23 @@ func SkipIfIdUnsupported(t *testing.T) {
139167func SkipIfIdSupported (t * testing.T ) {
140168 t .Helper ()
141169
142- skipIfGreaterOrEqual (t , "id requests" , 2 , 10 , 0 )
170+ SkipIfFeatureSupported (t , "id requests" , 2 , 10 , 0 )
143171}
144172
145173// SkipIfErrorExtendedInfoUnsupported skips test run if Tarantool without
146174// IPROTO_ERROR (0x52) support is used.
147175func SkipIfErrorExtendedInfoUnsupported (t * testing.T ) {
148176 t .Helper ()
149177
150- skipIfLess (t , "error extended info" , 2 , 4 , 1 )
178+ SkipIfFeatureUnsupported (t , "error extended info" , 2 , 4 , 1 )
151179}
152180
153181// SkipIfErrorMessagePackTypeUnsupported skips test run if Tarantool without
154182// MP_ERROR type over iproto support is used.
155183func SkipIfErrorMessagePackTypeUnsupported (t * testing.T ) {
156184 t .Helper ()
157185
158- skipIfLess (t , "error type in MessagePack" , 2 , 10 , 0 )
186+ SkipIfFeatureUnsupported (t , "error type in MessagePack" , 2 , 10 , 0 )
159187}
160188
161189// CheckEqualBoxErrors checks equivalence of tarantool.BoxError objects.
0 commit comments