const std = @import("std"); const testing = std.testing; test "sync command argument parsing" { // Test various sync command argument combinations const test_cases = [_]struct { args: []const []const u8, expected_path: ?[]const u8, expected_name: ?[]const u8, expected_queue: bool, expected_priority: ?u32, }{ .{ .args = &[_][]const u8{"/tmp/test"}, .expected_path = "/tmp/test", .expected_name = null, .expected_queue = false, .expected_priority = null }, .{ .args = &[_][]const u8{ "/tmp/test", "--name", "test_job" }, .expected_path = "/tmp/test", .expected_name = "test_job", .expected_queue = false, .expected_priority = null }, .{ .args = &[_][]const u8{ "/tmp/test", "--queue" }, .expected_path = "/tmp/test", .expected_name = null, .expected_queue = true, .expected_priority = null }, .{ .args = &[_][]const u8{ "/tmp/test", "--priority", "5" }, .expected_path = "/tmp/test", .expected_name = null, .expected_queue = false, .expected_priority = 5 }, }; for (test_cases) |case| { // For now, just verify the arguments are valid try testing.expect(case.args.len >= 1); try testing.expect(case.args[0].len > 0); if (case.expected_path) |path| { try testing.expect(std.mem.eql(u8, case.args[0], path)); } } } test "sync path validation" { // Test various path scenarios const test_paths = [_]struct { path: []const u8, should_be_valid: bool, }{ .{ .path = "/tmp/test", .should_be_valid = true }, .{ .path = "./relative", .should_be_valid = true }, .{ .path = "../parent", .should_be_valid = true }, .{ .path = "", .should_be_valid = false }, .{ .path = " ", .should_be_valid = false }, }; for (test_paths) |case| { if (case.should_be_valid) { try testing.expect(case.path.len > 0); try testing.expect(!std.mem.eql(u8, case.path, "")); } else { try testing.expect(case.path.len == 0 or std.mem.eql(u8, case.path, " ")); } } } test "sync priority validation" { // Test priority values const test_priorities = [_]struct { priority_str: []const u8, should_be_valid: bool, expected_value: ?u32, }{ .{ .priority_str = "0", .should_be_valid = true, .expected_value = 0 }, .{ .priority_str = "5", .should_be_valid = true, .expected_value = 5 }, .{ .priority_str = "10", .should_be_valid = true, .expected_value = 10 }, .{ .priority_str = "-1", .should_be_valid = false, .expected_value = null }, .{ .priority_str = "abc", .should_be_valid = false, .expected_value = null }, .{ .priority_str = "", .should_be_valid = false, .expected_value = null }, }; for (test_priorities) |case| { if (case.should_be_valid) { const parsed = std.fmt.parseInt(u32, case.priority_str, 10) catch |err| switch (err) { error.InvalidCharacter => null, else => null, }; if (parsed) |value| { try testing.expect(value == case.expected_value.?); } } } } test "sync job name validation" { // Test job name validation const test_names = [_]struct { name: []const u8, should_be_valid: bool, }{ .{ .name = "valid_job_name", .should_be_valid = true }, .{ .name = "job123", .should_be_valid = true }, .{ .name = "job-with-dash", .should_be_valid = true }, .{ .name = "", .should_be_valid = false }, .{ .name = " ", .should_be_valid = false }, .{ .name = "job with spaces", .should_be_valid = false }, .{ .name = "job/with/slashes", .should_be_valid = false }, }; for (test_names) |case| { if (case.should_be_valid) { try testing.expect(case.name.len > 0); try testing.expect(std.mem.indexOf(u8, case.name, " ") == null); try testing.expect(std.mem.indexOf(u8, case.name, "/") == null); } else { try testing.expect(case.name.len == 0 or std.mem.indexOf(u8, case.name, " ") != null or std.mem.indexOf(u8, case.name, "/") != null); } } }