feat: add unit tests for Go backend #16

Closed
Cloudy (Bot) wants to merge 3 commits from (deleted):feature/unit-tests into main
Collaborator

Closes #15

What

Unit tests for the testable components:

  • config_test.go - Config loading, defaults, validation, URL helpers
  • url_path_helper_test.go - URL path parsing and element access
  • utils_test.go - InsertStringAfterSubstring helper

Test Setup

  • Minimal setup, no external dependencies
  • Uses only Go stdlib testing package
  • Self-contained test files

Note

Tests require Go 1.24+ (for scs/v2 compatibility). Will run in CI.


@leon du darfst gerne schauen ob die Testabdeckung so passt oder ob noch was fehlt!

Closes #15 ## What Unit tests for the testable components: - `config_test.go` - Config loading, defaults, validation, URL helpers - `url_path_helper_test.go` - URL path parsing and element access - `utils_test.go` - InsertStringAfterSubstring helper ## Test Setup - Minimal setup, no external dependencies - Uses only Go stdlib `testing` package - Self-contained test files ## Note Tests require Go 1.24+ (for scs/v2 compatibility). Will run in CI. --- @leon du darfst gerne schauen ob die Testabdeckung so passt oder ob noch was fehlt!
- config_test.go: tests for config loading, defaults, validation, and URL helpers
- url_path_helper_test.go: tests for URL path parsing and element access
- utils_test.go: tests for InsertStringAfterSubstring helper

Tests are self-contained with no external dependencies. Minimal setup using
stdlib testing package only.
Owner

@cloudy kannst du noch den Forgejo Workflow anpassen, dass der die unit tests dann auch durchführt?

@cloudy kannst du noch den Forgejo Workflow anpassen, dass der die unit tests dann auch durchführt?
Author
Collaborator

👋 Hab den Kommentar gesehen! Ich werde jetzt den Forgejo Workflow anpassen, um die Unit Tests in der CI auszuführen.

👋 Hab den Kommentar gesehen! Ich werde jetzt den Forgejo Workflow anpassen, um die Unit Tests in der CI auszuführen.
feat(ci): add unit test job to CI workflow
Some checks failed
/ test (pull_request) Has been cancelled
/ docker-build-and-push (pull_request) Has been cancelled
0d3762f8ef
- Add new 'test' job running on PRs and pushes to main
- Tests run in golang:1.24-alpine container
- Docker build now depends on passing tests
- Docker build only runs on push to main (not on PRs)
- Added test files (*_test.go) to path triggers
Author
Collaborator

Workflow angepasst!

Ich habe den .forgejo/workflows/ci-main.yml erweitert:

Neu:

  • test Job, der bei PRs und Pushes auf main läuft
  • Nutzt golang:1.24-alpine Container
  • Führt go test -v ./... aus

Geändert:

  • docker-build-and-push hängt jetzt von erfolgreichem Test-Job ab
  • Docker-Build läuft nur noch bei Pushes auf main (nicht bei PRs)
  • Test-Dateien (*_test.go) zu den Triggern hinzugefügt

Commit: 0d3762f

✅ **Workflow angepasst!** Ich habe den `.forgejo/workflows/ci-main.yml` erweitert: **Neu:** - `test` Job, der bei PRs und Pushes auf main läuft - Nutzt `golang:1.24-alpine` Container - Führt `go test -v ./...` aus **Geändert:** - `docker-build-and-push` hängt jetzt von erfolgreichem Test-Job ab - Docker-Build läuft nur noch bei Pushes auf main (nicht bei PRs) - Test-Dateien (`*_test.go`) zu den Triggern hinzugefügt Commit: `0d3762f`
Owner

@cloudy mach bitte die ci-main anders. Ich will nen Test Workflow der in prs und main läuft und release, der wie schon bestehend auf tags läuft aber trotzdem vorher die tags macht. Die ci-main kannst du dann glaub entfernen.

@cloudy mach bitte die ci-main anders. Ich will nen Test Workflow der in prs und main läuft und release, der wie schon bestehend auf tags läuft aber trotzdem vorher die tags macht. Die ci-main kannst du dann glaub entfernen.
Author
Collaborator

Gelesen! Ich werde:

  1. test.yml erstellen → Tests laufen in PRs und auf main
  2. release.yml anpassen → Workflow erstellt Tags selbst vor dem Release
  3. ci-main.yml entfernen

Ich arbeite direkt auf diesem Branch weiter.

✅ Gelesen! Ich werde: 1. **test.yml** erstellen → Tests laufen in PRs und auf main 2. **release.yml** anpassen → Workflow erstellt Tags selbst vor dem Release 3. **ci-main.yml** entfernen Ich arbeite direkt auf diesem Branch weiter.
refactor(ci): restructure workflows
Some checks failed
Test / test (pull_request) Has been cancelled
00041cc5d6
- test.yml: runs tests on PRs and main branch pushes
- release.yml: auto-creates version tags before building and releasing
- removed ci-main.yml (functionality split into test.yml and release.yml)
Author
Collaborator

Fertig! Workflows umstrukturiert:

test.yml (neu)

  • Läuft bei Pushes auf main und in PRs
  • Führt go test -v ./... aus

release.yml (aktualisiert)

  • Läuft bei Pushes auf main (und manuell via workflow_dispatch)
  • Erstellt automatisch einen neuen Patch-Tag (vX.Y.Z+1)
  • Baut und pushed Docker-Image mit Versionstag
  • Erstellt das Forgejo-Release

ci-main.yml (gelöscht)

  • Funktionalität aufgeteilt in test.yml und release.yml

Commit: 00041cc

✅ **Fertig!** Workflows umstrukturiert: **test.yml** (neu) - Läuft bei Pushes auf `main` und in PRs - Führt `go test -v ./...` aus **release.yml** (aktualisiert) - Läuft bei Pushes auf `main` (und manuell via workflow_dispatch) - Erstellt automatisch einen neuen Patch-Tag (vX.Y.Z+1) - Baut und pushed Docker-Image mit Versionstag - Erstellt das Forgejo-Release **ci-main.yml** (gelöscht) - Funktionalität aufgeteilt in test.yml und release.yml Commit: `00041cc`
Cloudy (Bot) closed this pull request 2026-03-28 21:34:20 +01:00
Some checks failed
Test / test (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
leon/Forge-Pages!16
No description provided.