ReviewOS

also looking at this

zig-utils/zig-test-framework

test: make CI exercise maintained integrations

#18
Merged glennmichael123 wants to merge codex/issue-3-test-coverage into main
16 files +390 -139
tests/mock_test.zigmodified+27-12
Changes to tests/mock_test.zig
@@ -1,19 +1,34 @@
11const std = ;
2const ztf = ;
23
3// Placeholder tests for mock module
4// TODO: Implement comprehensive tests for mocking and spying
5
6test "mock function call tracking" {
7 // Test mock call recording
8 try std.testing.expect(true);
4test "mock records calls and exposes the latest invocation" {
5 var mock = ztf.createMock(std.testing.allocator, i32);
6 defer mock.deinit();
7 try mock.recordCall("first");
8 try mock.recordCall("second");
9 try std.testing.expectEqual(@as(usize, 2), mock.callCount());
10 try std.testing.expectEqualStrings("second", mock.getLastCall().?.args);
11 try mock.toHaveBeenCalledWith("first");
912}
1013
11test "mock return values" {
12 // Test mock return value functionality
13 try std.testing.expect(true);
14test "mock returns configured values in order" {
15 var mock = ztf.createMock(std.testing.allocator, i32);
16 defer mock.deinit();
17 _ = try mock.mockReturnValueOnce(10);
18 _ = try mock.mockReturnValue(20);
19 try std.testing.expectEqual(@as(?i32, 10), mock.getReturnValue());
20 try std.testing.expectEqual(@as(?i32, 20), mock.getReturnValue());
21 try std.testing.expectEqual(@as(?i32, 20), mock.getReturnValue());
1422}
1523
16test "spy functionality" {
17 // Test spy wrapping of functions
18 try std.testing.expect(true);
24test "mock clear preserves return values while reset removes them" {
25 var mock = ztf.createMock(std.testing.allocator, i32);
26 defer mock.deinit();
27 try mock.recordCall("call");
28 _ = try mock.mockReturnValue(7);
29 _ = mock.mockClear();
30 try std.testing.expectEqual(@as(usize, 0), mock.callCount());
31 try std.testing.expectEqual(@as(?i32, 7), mock.getReturnValue());
32 _ = mock.mockReset();
33 try std.testing.expectEqual(@as(?i32, null), mock.getReturnValue());
1934}