Skip to content

Commit f917e9f

Browse files
committed
Now skips session tests if version is >= 10.2
1 parent dce1deb commit f917e9f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/java/org/gitlab4j/api/TestGitLabSession.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.junit.Assume.assumeTrue;
66

77
import org.gitlab4j.api.GitLabApi.ApiVersion;
8+
import org.gitlab4j.api.models.Version;
89
import org.junit.Before;
910
import org.junit.BeforeClass;
1011
import org.junit.Test;
@@ -60,6 +61,27 @@ public static void setup() {
6061
problems += "TEST_PRIVATE_TOKEN cannot be empty\n";
6162
}
6263

64+
if (problems.isEmpty()) {
65+
String savedVersion = null;
66+
try {
67+
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN);
68+
Version version = gitLabApi.getVersion();
69+
savedVersion = version.getVersion();
70+
String[] parts = version.getVersion().split(".", -1);
71+
if (parts.length == 3) {
72+
if (Integer.parseInt(parts[0]) < 10 ||
73+
(Integer.parseInt(parts[0]) == 10 && Integer.parseInt(parts[1]) < 2)) {
74+
savedVersion = null;
75+
}
76+
}
77+
} catch (Exception e) {
78+
}
79+
80+
if (savedVersion != null) {
81+
problems += "GitLab version " + savedVersion + " does not support sessions\n";
82+
}
83+
}
84+
6385
if (!problems.isEmpty()) {
6486
System.err.print(problems);
6587
}

0 commit comments

Comments
 (0)