Skip to content

Commit

Permalink
github actions unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar committed Nov 29, 2023
1 parent 26a00fb commit 3ba0e1e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ jobs:

- name: Execute Gradle build
run: ./gradlew build


- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success()
with:
fail_on_failure: true
report_paths: '**/build/test-results/test/TEST-*.xml'

- name: Rename File
run: |
mv ${{ github.workspace }}/build/libs/sqlib.jar ${{ github.workspace }}/sqlib-${{ github.event.release.tag_name }}.jar;
Expand All @@ -42,6 +49,19 @@ jobs:
${{ github.workspace }}/sqlib-${{ github.event.release.tag_name }}-sources.jar
java: 17
game-versions: |
>=1.16.5
1.20.2
1.20.1
1.20
1.19.4
1.19.3
1.19.2
1.19.1
1.19
1.18.2
1.18.1
1.18
1.17.1
1.17
1.16.5
dependencies: |
fabric-api
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run Tests
on:
push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Execute Gradle build
run: ./gradlew build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success()
with:
fail_on_failure: true
report_paths: '**/build/test-results/test/TEST-*.xml'
5 changes: 0 additions & 5 deletions jitpack.yml

This file was deleted.

7 changes: 3 additions & 4 deletions src/test/java/me/mrnavastar/sqlib/SQLibTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

public class SQLibTest {

private static final Database database = new SQLiteDatabase("test", ".");

private final String testString = "Test String";
private final int testInt = 37;
private final double testDouble = Math.PI;
Expand All @@ -35,7 +37,6 @@ public class SQLibTest {

@Test
public void testAllTransactions() {
Database database = database = new SQLiteDatabase("test", ".");
Table table = database.createTable("test", "table1")
.addColumn("string", SQLDataType.STRING)
.addColumn("int", SQLDataType.INT)
Expand Down Expand Up @@ -99,12 +100,10 @@ public void testAllTransactions() {
dataContainer.clear("identifier");

table.endTransaction();
database.close();
}

@Test
public void testTableFunctions() {
Database database = new SQLiteDatabase("test", ".");
Table table = database.createTable("test", "table2")
.addColumn("test", SQLDataType.STRING)
.finish();
Expand Down Expand Up @@ -134,11 +133,11 @@ public void testTableFunctions() {
assertFalse(table.contains(dataContainer3.getIdAsString()));

assertEquals(0, table.getDataContainers().size());
database.close();
}

@AfterAll
public static void cleanup() {
database.close();
new File("test.db").delete();
}
}

0 comments on commit 3ba0e1e

Please sign in to comment.