blob: 3b169148483768e7e19d236256a9eb638bc3640d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
const std = @import("std");
const ssh = @import("ssh.zig");
pub fn main() anyerror!void {
var client = ssh.Client.init("localhost") catch unreachable;
const stdout = std.io.getStdOut();
client.run("pwd", stdout) catch unreachable;
client.run("who", stdout) catch unreachable;
client.deinit();
}
test "basic test" {
// this test requires you can ssh localhost without a password prompt
// (typically by having your ssh_agent running)
var client = ssh.Client.init("localhost") catch unreachable;
var buffer = std.ArrayList(u8).init(std.testing.allocator);
defer buffer.deinit();
client.run("echo test", buffer.writer()) catch unreachable;
try std.testing.expectEqualSlices(u8, buffer.items, "test\n");
client.deinit();
}
|