╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_ssh.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
708 try sess.exit(1); 709 } 710 711 test "parseGitCommand rejects malformed input" { 712 const allocator = std.testing.allocator; 713 try std.testing.expectError(error.InvalidCommand, parseGitCommand(allocator, "git-upload-pack")); 714 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "ls -la")); 715 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "git-fake-pack 'repo'")); 716 } 717 718 test "parseGitCommand happy paths" { 719 const allocator = std.testing.allocator; 720 721 { 722 const parsed = try parseGitCommand(allocator, "git-upload-pack 'some-repo'"); 723 defer parsed.deinit(allocator); 724 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 725 try std.testing.expectEqualStrings("some-repo", parsed.dir); 726 } 727 { 728 const parsed = try parseGitCommand(allocator, "git-receive-pack 'user/proj'"); 729 defer parsed.deinit(allocator); 730 try std.testing.expectEqual(GitService.receive_pack, parsed.service); 731 try std.testing.expectEqualStrings("user/proj", parsed.dir); 732 } 733 { 734 const parsed = try parseGitCommand(allocator, "git-upload-pack repo"); 735 defer parsed.deinit(allocator); 736 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 737 try std.testing.expectEqualStrings("repo", parsed.dir); 738 } 739 } 740