Skip to content

Commit bf5ca82

Browse files
tilgalascopybara-github
authored andcommitted
chore: update VersionTest to allow rc versions
PiperOrigin-RevId: 886723823
1 parent 8ba4bfe commit bf5ca82

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

core/src/test/java/com/google/adk/VersionTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,31 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21+
import java.util.regex.Pattern;
2122
import org.junit.Test;
2223
import org.junit.runner.RunWith;
2324
import org.junit.runners.JUnit4;
2425

2526
@RunWith(JUnit4.class)
2627
public class VersionTest {
2728

29+
// from semver.org
30+
private static final Pattern SEM_VER =
31+
Pattern.compile(
32+
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
33+
2834
@Test
2935
public void versionShouldMatchProjectVersion() {
3036
assertThat(Version.JAVA_ADK_VERSION).isNotNull();
3137
assertThat(Version.JAVA_ADK_VERSION).isNotEmpty();
3238
assertThat(Version.JAVA_ADK_VERSION).isNotEqualTo("unknown");
3339
assertThat(Version.JAVA_ADK_VERSION).isNotEqualTo("${project.version}");
3440

35-
assertThat(Version.JAVA_ADK_VERSION).matches("\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?");
41+
assertThat(Version.JAVA_ADK_VERSION).matches("\\d+\\.\\d+\\.\\d+(-SNAPSHOT|-rc\\.\\d+)?");
42+
}
43+
44+
@Test
45+
public void versionShouldFollowSemanticVersioning() {
46+
assertThat(Version.JAVA_ADK_VERSION).matches(SEM_VER);
3647
}
3748
}

0 commit comments

Comments
 (0)