test: notification handler + gotify client unit tests

- 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 15:14:13 +09:00
parent 65928b109b
commit df6f8165b6
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))
}