Skip to content

Commit

Permalink
parameterize
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Oct 15, 2024
1 parent 27f3858 commit 0a6a578
Showing 1 changed file with 9 additions and 34 deletions.
43 changes: 9 additions & 34 deletions src/test/java/io/cryostat/agent/VersionInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,21 @@

import io.cryostat.agent.VersionInfo.Semver;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

public class VersionInfoTest {

static final Semver serverMin = Semver.fromString("1.0.0");
static final Semver serverMax = Semver.fromString("2.0.0");

@Test
public void testActualEqualsMin() {
@ParameterizedTest
@CsvSource({"1.0.0, true", "2.0.0, false", "3.0.0, false", "0.1.0, false", "1.1.0, true"})
public void test(String serverVersion, boolean inRange) {
VersionInfo info = new VersionInfo(Semver.UNKNOWN, serverMin, serverMax);
Semver actual = Semver.fromString("1.0.0");
Assertions.assertTrue(info.validateServerVersion(actual));
}

@Test
public void testActualEqualsMax() {
VersionInfo info = new VersionInfo(Semver.UNKNOWN, serverMin, serverMax);
Semver actual = Semver.fromString("2.0.0");
Assertions.assertFalse(info.validateServerVersion(actual));
}

@Test
public void testActualGreaterMax() {
VersionInfo info = new VersionInfo(Semver.UNKNOWN, serverMin, serverMax);
Semver actual = Semver.fromString("3.0.0");
Assertions.assertFalse(info.validateServerVersion(actual));
}

@Test
public void testActualLesserMin() {
VersionInfo info = new VersionInfo(Semver.UNKNOWN, serverMin, serverMax);
Semver actual = Semver.fromString("0.1.0");
Assertions.assertFalse(info.validateServerVersion(actual));
}

@Test
public void testActualInRange() {
VersionInfo info = new VersionInfo(Semver.UNKNOWN, serverMin, serverMax);
Semver actual = Semver.fromString("1.1.0");
Assertions.assertTrue(info.validateServerVersion(actual));
Semver actual = Semver.fromString(serverVersion);
MatcherAssert.assertThat(info.validateServerVersion(actual), Matchers.equalTo(inRange));
}
}

0 comments on commit 0a6a578

Please sign in to comment.