Add unit tests covering error paths and malformed API responses #8

Open
opened 2026-04-07 11:05:58 +01:00 by mon · 0 comments
Owner

Some error paths in UpdateDnsCommand and related classes are not currently covered by tests. Adding tests for these scenarios would improve confidence in error handling and prevent regressions.

Suggested test cases

  • retrieve() returns invalid JSON
  • retrieve() returns missing fields (e.g., missing records)
  • Individual DNS records missing required fields (id, content, etc.)
  • edit() returns non‑SUCCESS status
  • ping() returns null or malformed data
  • Config file contains valid JSON but wrong structure

Benefits

  • Stronger guarantees around error handling
  • Prevents unnoticed regressions
  • Makes future refactoring safer

Notes

  • Tests should not require real API calls
  • Mocking should simulate malformed responses
Some error paths in `UpdateDnsCommand` and related classes are not currently covered by tests. Adding tests for these scenarios would improve confidence in error handling and prevent regressions. **Suggested test cases** - `retrieve()` returns invalid JSON - `retrieve()` returns missing fields (e.g., missing records) - Individual DNS records missing required fields (id, content, etc.) - `edit()` returns non‑SUCCESS status - `ping()` returns null or malformed data - `Config` file contains valid JSON but wrong structure **Benefits** - Stronger guarantees around error handling - Prevents unnoticed regressions - Makes future refactoring safer **Notes** - Tests should not require real API calls - Mocking should simulate malformed responses
mon self-assigned this 2026-04-07 11:06:05 +01:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 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: mon/pb-dydns#8
No description provided.