I created a utility class to spawn a NATS server. This assumes it is installed and in PATH, which should be easy enough to accomplish for a CI environment. The current approach will not work with parallel tests, but that's not a practical reality, so this route should be fine for the time being. It might be nice to spawn a default server at the beginning of testing and tear it down at the end, to save waiting for the startup/shutdown time in many individual tests. This makes me wonder: if I initialize a server in the beginning of the `test` block in main that imports the other modules, does that scope stay live while the "child" tests are running? My default guess would be probably not, but that would be very convenient, so I might try it out and see.
19 lines
419 B
Zig
19 lines
419 B
Zig
const std = @import("std");
|
|
|
|
const nats = @import("nats");
|
|
|
|
const util = @import("./util.zig");
|
|
|
|
test "nats.Connection.connectTo" {
|
|
var server = try util.TestServer.launch(.{});
|
|
defer server.stop();
|
|
|
|
{
|
|
try nats.init(nats.default_spin_count);
|
|
defer nats.deinit();
|
|
|
|
const connection = try nats.Connection.connectTo(nats.default_server_url);
|
|
defer connection.destroy();
|
|
}
|
|
}
|