Skip to content

Commit

Permalink
test: support codecov (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes committed Apr 7, 2024
1 parent 1aac164 commit 8f3588c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 22 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,19 @@ jobs:
java: [ 8, 21 ]
steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Set up Java JDK"
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: "Print maven version"
run: ./mvnw -version
- name: "Test, Check style, Check PMD, Check license with Maven and Java8"
if: matrix.java == '8'
- name: "Test, Check style, Check PMD, Check license with Maven and Java"
run: |
./mvnw -T 4C clean test && sh ./tools/check_format.sh
- name: "Test with Maven and Java${{ matrix.java }}"
if: matrix.java != '8'
run: |
./mvnw -T 4C clean test
- name: "Codecov"
if: matrix.java == '8'
uses: codecov/[email protected]
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ coverage:
precision: 2
range: "50...100"
ignore:
- ".github/.*"
- ".mvn/.*"
- ".style/.*"
- "*.md"
- ".github/.*"
- ".mvn/.*"
- ".style/.*"
- "*.md"
comment:
layout: "reach,diff,flags,tree"
behavior: default
Expand Down
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,26 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
20 changes: 11 additions & 9 deletions src/test/java/icu/funkye/redispike/ServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public class ServerTest {
static Server server;
static IAerospikeClient aspClient;

static Logger logger = LoggerFactory.getLogger(ServerTest.class);
static Logger logger = LoggerFactory.getLogger(ServerTest.class);

private final int RandomValue = Integer.MAX_VALUE;

@BeforeAll
public static void init() throws ParseException {
Expand All @@ -53,7 +55,7 @@ public static void init() throws ParseException {

@Test
public void testhHash() {
String key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
String key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
Long result = jedis.hset(key.getBytes(StandardCharsets.UTF_8), "b".getBytes(StandardCharsets.UTF_8),
"c".getBytes(StandardCharsets.UTF_8));
Expand All @@ -67,7 +69,7 @@ public void testhHash() {
Assertions.assertEquals(result, 2);
result = jedis.hdel(key, map.keySet().toArray(new String[0]));
Assertions.assertEquals(result, 2);
key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
result = jedis.hsetnx(key, "f", "g");
Assertions.assertEquals(result, 1);
result = jedis.hsetnx(key, "f", "g");
Expand Down Expand Up @@ -114,7 +116,7 @@ public void testGetNilAsp() {

@Test
public void testSetExAsp() {
String key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
String key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
String result = jedis.set(key, "b", SetParams.setParams().ex(1L));
Assertions.assertEquals(result, "OK");
Expand All @@ -128,13 +130,13 @@ public void testSetExAsp() {

@Test
public void testSetNxNilAsp() {
String key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
String key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
String result = jedis.set(key, "b", SetParams.setParams().nx());
Assertions.assertEquals(result, "OK");
result = jedis.set(key, "b", SetParams.setParams().nx());
Assertions.assertNull(result);
key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
result = String.valueOf(jedis.setnx(key, "b"));
Assertions.assertEquals(result, "1");
result = String.valueOf(jedis.setnx(key, "b"));
Expand All @@ -144,7 +146,7 @@ public void testSetNxNilAsp() {

@Test
public void testSetExNxAsp() {
String key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
String key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
String result = jedis.set(key, "b", SetParams.setParams().nx().ex(1L));
Assertions.assertEquals(result, "OK");
Expand All @@ -158,7 +160,7 @@ public void testSetExNxAsp() {

@Test
public void testDelAsp() {
String key = String.valueOf(ThreadLocalRandom.current().nextInt(50000));
String key = String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue));
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
String result = jedis.set(key, "b");
Assertions.assertEquals(result, "OK");
Expand All @@ -171,7 +173,7 @@ public void testDelAsp() {
public void testBatchDelAsp() {
List<String> keys = new ArrayList<>();
for (int i = 0; i < 2; i++) {
keys.add(String.valueOf(ThreadLocalRandom.current().nextInt(50000)));
keys.add(String.valueOf(ThreadLocalRandom.current().nextInt(RandomValue)));
}
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
String result = jedis.set(keys.get(0), "b");
Expand Down

0 comments on commit 8f3588c

Please sign in to comment.