Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 20c29c4

Browse files
committed
Feat: Unit tests and general adjustments
1 parent 81add74 commit 20c29c4

20 files changed

Lines changed: 280 additions & 207 deletions

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
*.dot
77
*.mmd
88
*.lock
9+
src/tests
10+
.github
11+
.local-tests

.github/workflows/docker.yaml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,29 @@ jobs:
1515
name: Test Build on Push
1616
runs-on: ubuntu-latest
1717
steps:
18+
- uses: oven-sh/setup-bun@v2
19+
name: Setup Bun
20+
with:
21+
bun-version: latest
22+
1823
- name: Checkout repository
1924
uses: actions/checkout@v4
2025

21-
- name: Set up QEMU
22-
uses: docker/setup-qemu-action@v3
26+
- name: Run Unit-tests
27+
run: |
28+
bun install
29+
bun clean
30+
bun test
2331
24-
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v3
32+
- name: Run Docker Build
33+
run: |
34+
bun build:docker
2635
27-
- name: Build image for testing
28-
uses: docker/build-push-action@v6
29-
with:
30-
context: .
31-
file: docker/Dockerfile
32-
load: true
33-
# build only for current architecture (usually linux/amd64) to enable local loading
34-
platforms: linux/amd64
35-
tags: dockstatapi:test
36+
- name: Start docker container
37+
run: |
38+
docker run --name dockstatapi --rm -d dockstatapi:local
39+
sleep 10
40+
if [[ $(docker container ls | grep "Up" | wc -l) -gt 0 ]]; then docker kill dockstatapi && exit 0; else; exit 1; fi
3641
3742
release:
3843
name: Build and Push Docker Image on Release

out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="bun test" tests="11" assertions="13" failures="0" skipped="0" time="4.848594">
3+
<testsuite name="src\tests\gets.spec.ts" tests="8" assertions="8" failures="0" skipped="0" time="1.875" hostname="">
4+
<testcase name="Check Server connection" classname="DockStatAPI (GET)" time="0.016" file="src\tests\gets.spec.ts" assertions="1" />
5+
<testcase name="Check /docker/containers" classname="DockStatAPI (GET)" time="1.828" file="src\tests\gets.spec.ts" assertions="1" />
6+
<testcase name="Check /docker/hosts/Localhost" classname="DockStatAPI (GET)" time="0.016" file="src\tests\gets.spec.ts" assertions="1" />
7+
<testcase name="Check /docker-config/hosts" classname="DockStatAPI (GET)" time="0" file="src\tests\gets.spec.ts" assertions="1" />
8+
<testcase name="Check /logs/" classname="DockStatAPI (GET)" time="0.015" file="src\tests\gets.spec.ts" assertions="1" />
9+
<testcase name="Check /logs/debug" classname="DockStatAPI (GET)" time="0" file="src\tests\gets.spec.ts" assertions="1" />
10+
<testcase name="Check /config" classname="DockStatAPI (GET)" time="0" file="src\tests\gets.spec.ts" assertions="1" />
11+
<testcase name="Check /config/package" classname="DockStatAPI (GET)" time="0" file="src\tests\gets.spec.ts" assertions="1" />
12+
</testsuite>
13+
<testsuite name="src\tests\post.spec.ts" tests="3" assertions="5" failures="0" skipped="0" time="0.172" hostname="">
14+
<testcase name="Check Host adding" classname="DockStatAPI (POST)" time="0.047" file="src\tests\post.spec.ts" assertions="2" />
15+
<testcase name="Check Host Updating" classname="DockStatAPI (POST)" time="0.016" file="src\tests\post.spec.ts" assertions="2" />
16+
<testcase name="Check Config update" classname="DockStatAPI (POST)" time="0.109" file="src\tests\post.spec.ts" assertions="1" />
17+
</testsuite>
18+
</testsuites>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"description": "DockStatAPI is an API backend featuring plugins and more for DockStat",
1111
"version": "3.0.0",
1212
"scripts": {
13-
"test": "bun clean && bun test && bun run ./src/tests/cleanup.ts",
1413
"start": "cross-env NODE_ENV=production LOG_LEVEL=info bun run src/index.ts",
14+
"start:docker": "bun run build:docker && docker run -p 3001:3000 --rm -d --name dockstatapi -v 'plugins:/DockStatAPI/src/plugins' dockstatapi:local",
1515
"dev": "docker compose -f docker/docker-compose.dev.yaml up -d && cross-env NODE_ENV=dev bun run --watch src/index.ts",
1616
"dev:clean": "bun dev ; echo '\nExiting...' ; bun clean",
1717
"build": "bun build --target bun src/index.ts --outdir ./dist",
18+
"build:docker": "docker build -f docker/Dockerfile . -t 'dockstatapi:local'",
1819
"clean": "bun run clean:win || bun run clean:lin",
1920
"clean:win": "node -e \"process.exit(process.platform === 'win32' ? 0 : 1)\" && cmd /c del /Q dockstatapi.db* && echo 'success'",
2021
"clean:lin": "node -e \"process.exit(process.platform !== 'win32' ? 0 : 1)\" && rm -f dockstatapi.db* && echo 'success'",

0 commit comments

Comments
 (0)