4 Commits

Author SHA1 Message Date
Mauro 4bdf8f0e1d Merge pull request #1829 from perhapzz/test/add-fileutil-health-tests
test: add unit tests for pkg/fileutil and pkg/health
2026-03-26 10:42:13 +01:00
Cytown cf9e0496f7 fix launcher can't save model api_key issue (#1928)
* fix launcher can't save model api_key issue

* add backup for old data before migrate config and fix migrate to empty
security issue
2026-03-24 03:26:11 +01:00
perhapzz 0276554d9c test(fileutil,health): add unit tests for WriteFileAtomic and health server
Add comprehensive test coverage for two previously untested packages:

pkg/fileutil (9 tests):
- Basic write and read-back
- File permissions (0600)
- Overwrite existing files
- Empty data handling
- Nested directory auto-creation
- No temp files left after success
- Large file (1MB) handling
- Concurrent write safety
- Invalid path error handling

pkg/health (15 tests):
- Health endpoint returns 200 with status, uptime, pid
- Ready endpoint returns 503 when not ready
- Ready endpoint returns 200 when ready
- Ready fails when any registered check fails
- Ready passes with all checks passing
- Reload rejects non-POST methods
- Reload returns 503 when no reload func set
- Reload calls registered function on success
- Reload returns 500 on function error
- SetReady toggle behavior
- Multiple health checks interaction
- RegisterOnMux works with custom ServeMux
- NewServer defaults
- StartContext graceful shutdown on cancel
- statusString helper
2026-03-20 10:41:08 +00:00
mosir 11996f1a0b refactor(pkg): move atomic file write to dedicated fileutil package 2026-02-24 23:57:13 +08:00