Fix date parsing for Checkvist API format
Add custom APITime type with UnmarshalJSON to handle the non-standard
date format returned by the Checkvist API ("2026/01/14 16:07:31 +0000")
instead of the expected RFC3339 format.
Changes:
- Add APITime type with custom JSON marshaling/unmarshaling in models.go
- Replace time.Time with APITime for UpdatedAt/CreatedAt fields in
Checklist, Task, and Note structs
- Add NewAPITime constructor for convenience
- Update test fixtures to use real API date format
- Add comprehensive unit tests for APITime in models_test.go
Fixes: checkvist-api-4qn
This commit is contained in:
parent
fa6b93e564
commit
e4862b8e9b
12 changed files with 241 additions and 30 deletions
|
|
@ -162,7 +162,7 @@ func TestChecklists_Create(t *testing.T) {
|
|||
Name: req.Name,
|
||||
Public: false,
|
||||
Archived: false,
|
||||
UpdatedAt: time.Now(),
|
||||
UpdatedAt: NewAPITime(time.Now()),
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
default:
|
||||
|
|
@ -208,7 +208,7 @@ func TestChecklists_Update(t *testing.T) {
|
|||
response := Checklist{
|
||||
ID: 1,
|
||||
Name: req.Name,
|
||||
UpdatedAt: time.Now(),
|
||||
UpdatedAt: NewAPITime(time.Now()),
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
default:
|
||||
|
|
@ -284,7 +284,7 @@ func TestChecklists_Archive(t *testing.T) {
|
|||
ID: 1,
|
||||
Name: "Archived Checklist",
|
||||
Archived: true,
|
||||
UpdatedAt: time.Now(),
|
||||
UpdatedAt: NewAPITime(time.Now()),
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
default:
|
||||
|
|
@ -328,7 +328,7 @@ func TestChecklists_Unarchive(t *testing.T) {
|
|||
ID: 1,
|
||||
Name: "Unarchived Checklist",
|
||||
Archived: false,
|
||||
UpdatedAt: time.Now(),
|
||||
UpdatedAt: NewAPITime(time.Now()),
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue