Logo
Explore Help
Sign In
factotum/nats.zig
1
Fork 0
You've already forked nats.zig
Code Issues Pull Requests Packages Projects Releases Wiki Activity
nats.zig/tests/connection.zig

19 lines
419 B
Zig
Raw Normal View History

tests: add basic connection test 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.
2023-08-27 18:10:53 -07:00
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();
}
}
Reference in New Issue Copy Permalink
Powered by Gitea
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API