test: notification handler + gotify client unit tests
CI / CI (pull_request) Successful in 3m11s

- 24 tests covering all X-Resource routes
- Mock Gotify server for message/application CRUD
- Error cases: nil gotify, invalid JSON, missing fields, 429, 500
- Fix readError() to handle io.ReadAll failure
- GotifyClient direct tests for all 7 methods
This commit is contained in:
Admin Bot
2026-09-15 10:01:11 +09:00
parent d16597ca0b
commit 234d2a2c02
2 changed files with 517 additions and 1 deletions
+4 -1
View File
@@ -252,6 +252,9 @@ func (c *GotifyClient) DeleteApplication(id int) error {
// --- Helpers ---
func (c *GotifyClient) readError(resp *http.Response) error {
body, _ := io.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("gotify API error (HTTP %d): failed to read body: %w", resp.StatusCode, err)
}
return fmt.Errorf("gotify API error (HTTP %d): %s", resp.StatusCode, string(body))
}