Skip to content

Commit

Permalink
Fix checking the current Tarantool version for minimum requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
valery1707 authored and akudiyar committed Oct 29, 2023
1 parent a86d4e8 commit 8600dd2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@
<version>1.35</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
22 changes: 13 additions & 9 deletions src/test/java/io/tarantool/driver/TarantoolUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ public final class TarantoolUtils {
private TarantoolUtils() {
}

public static boolean versionGreaterOrEqualThen(String tarantoolVersion) {
Assert.notNull(tarantoolVersion, "tarantoolVersion must not be null");
public static boolean versionGreaterOrEqualThen(String minimum) {
Assert.notNull(minimum, "minimum must not be null");
String tarantoolCiVersion = java.lang.System.getenv(TARANTOOL_VERSION);
if (tarantoolCiVersion == null || tarantoolCiVersion.isEmpty()) {
return true;
}
TarantoolVersion ciVersion = new TarantoolVersion(tarantoolCiVersion);
TarantoolVersion version = new TarantoolVersion(tarantoolVersion);
return ciVersion.getMajor() >= version.getMajor() &&
ciVersion.getMinor() >= version.getMinor();
return versionGreaterOrEqualThen(tarantoolCiVersion, minimum);
}

public static boolean versionGreaterOrEqualThen(String current, String minimum) {
return current == null || current.isEmpty() ||
versionGreaterOrEqualThen(new TarantoolVersion(current), new TarantoolVersion(minimum));
}

public static boolean versionGreaterOrEqualThen(TarantoolVersion current, TarantoolVersion minimum) {
return current.getMajor() > minimum.getMajor() ||
current.getMajor().equals(minimum.getMajor()) && current.getMinor() >= minimum.getMinor();
}

public static boolean versionWithUUID() {
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/io/tarantool/driver/TarantoolUtilsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.tarantool.driver;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import static io.tarantool.driver.TarantoolUtils.versionGreaterOrEqualThen;
import static org.junit.jupiter.api.Assertions.assertEquals;

class TarantoolUtilsTest {

@ParameterizedTest(name = "[{index}] {0} >= {1} == {2}")
@CsvSource(nullValues = "null", value = {
"null , 2.1 , true",
"'' , 2.1 , true",
"2.2 , 2.1 , true",
"2.2 , 2.2 , true",
"2.2.1 , 2.2 , true",
"2.2 , 2.2.1 , true",
"2.2.1 , 2.2.2 , true",
"2.x , 2.2 , true",
"2.x , 2.x , true",
"2.2 , 2.3 , false",
"3.2 , 2.3 , true",
})
void test_minimumVersionCheck(String current, String minimum, boolean expected) {
assertEquals(expected, versionGreaterOrEqualThen(current, minimum));
}

}

0 comments on commit 8600dd2

Please sign in to comment.