this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test: add mark_complete tests and fix missing save_tasks call

- fix mark_complete not persisting changes to storage
- add test for successful completion (status, updated_at, completed_at)
- add test for nonexistent task returning error.InvalidItem

Ben 6126d2eb 896726f5

+31 -2
+31 -2
src/core/task.zig
··· 125 125 task.status = .completed; 126 126 task.updated_at = std.time.timestamp(); 127 127 task.completed_at = std.time.timestamp(); 128 + try storage.save_tasks(arena.allocator(), dir, tasks); 128 129 return; 129 130 } 130 131 } ··· 210 211 var tmp_dir = std.testing.tmpDir(.{}); 211 212 defer tmp_dir.cleanup(); 212 213 213 - try add_task(allocator, "Some Task", tmp_dir.dir); 214 - 215 214 try std.testing.expectError(error.InvalidItem, delete_task(allocator, "999", tmp_dir.dir)); 216 215 } 217 216 ··· 224 223 // Should not error — just prints "No tasks" 225 224 try list_task(allocator, tmp_dir.dir); 226 225 } 226 + 227 + test "mark_complete sets status and timestamps" { 228 + const allocator = std.testing.allocator; 229 + var arena = std.heap.ArenaAllocator.init(allocator); 230 + defer arena.deinit(); 231 + 232 + var tmp_dir = std.testing.tmpDir(.{}); 233 + defer tmp_dir.cleanup(); 234 + 235 + try add_task(allocator, "Complete Me", tmp_dir.dir); 236 + 237 + const tasks = try storage.load_tasks(arena.allocator(), tmp_dir.dir); 238 + try mark_complete(allocator, tasks[0].id, tmp_dir.dir); 239 + 240 + const updated = try storage.load_tasks(arena.allocator(), tmp_dir.dir); 241 + try std.testing.expectEqual(updated[0].status, .completed); 242 + try std.testing.expect(updated[0].updated_at != null); 243 + try std.testing.expect(updated[0].completed_at != null); 244 + } 245 + 246 + test "mark_complete nonexistent task returns error" { 247 + const allocator = std.testing.allocator; 248 + 249 + var tmp_dir = std.testing.tmpDir(.{}); 250 + defer tmp_dir.cleanup(); 251 + 252 + try add_task(allocator, "Some Task", tmp_dir.dir); 253 + 254 + try std.testing.expectError(error.InvalidItem, mark_complete(allocator, "nonexistent-id", tmp_dir.dir)); 255 + }