╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_ssh.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
664 const allocator = std.testing.allocator; 665 try std.testing.expectError(error.InvalidCommand, parseGitCommand(allocator, "git-upload-pack")); 666 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "ls -la")); 667 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "git-fake-pack 'repo'")); 668 } 669 670 test "parseGitCommand happy paths" { 671 const allocator = std.testing.allocator; 672 673 { 674 const parsed = try parseGitCommand(allocator, "git-upload-pack 'some-repo'"); 675 defer parsed.deinit(allocator); 676 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 677 try std.testing.expectEqualStrings("some-repo", parsed.dir); 678 } 679 { 680 const parsed = try parseGitCommand(allocator, "git-receive-pack 'user/proj'"); 681 defer parsed.deinit(allocator); 682 try std.testing.expectEqual(GitService.receive_pack, parsed.service); 683 try std.testing.expectEqualStrings("user/proj", parsed.dir); 684 } 685 { 686 const parsed = try parseGitCommand(allocator, "git-upload-pack repo"); 687 defer parsed.deinit(allocator); 688 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 689 try std.testing.expectEqualStrings("repo", parsed.dir); 690 } 691 } 692