╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_ssh.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
637 try sess.writeBytes(line); 638 try sess.exit(1); 639 } 640 641 test "parseGitCommand rejects malformed input" { 642 const allocator = std.testing.allocator; 643 try std.testing.expectError(error.InvalidCommand, parseGitCommand(allocator, "git-upload-pack")); 644 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "ls -la")); 645 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "git-fake-pack 'repo'")); 646 } 647 648 test "parseGitCommand happy paths" { 649 const allocator = std.testing.allocator; 650 651 { 652 const parsed = try parseGitCommand(allocator, "git-upload-pack 'some-repo'"); 653 defer parsed.deinit(allocator); 654 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 655 try std.testing.expectEqualStrings("some-repo", parsed.dir); 656 } 657 { 658 const parsed = try parseGitCommand(allocator, "git-receive-pack 'user/proj'"); 659 defer parsed.deinit(allocator); 660 try std.testing.expectEqual(GitService.receive_pack, parsed.service); 661 try std.testing.expectEqualStrings("user/proj", parsed.dir); 662 } 663 { 664 const parsed = try parseGitCommand(allocator, "git-upload-pack repo"); 665 defer parsed.deinit(allocator); 666 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 667 try std.testing.expectEqualStrings("repo", parsed.dir); 668 } 669 } 670