fediglam/tests/api_integration/lib.zig

36 lines
915 B
Zig

const std = @import("std");
const main = @import("main");
const cluster_host = "test_host";
const test_config = .{
.cluster_host = cluster_host,
.db = .{
.sqlite = .{
.db_file = ":memory:",
},
},
};
const ApiSource = main.api.ApiSource;
const root_password = "password";
const random_seed = 1234;
fn makeApi(alloc: std.mem.Allocator) !ApiSource {
main.api.initThreadPrng(random_seed);
const source = try ApiSource.init(alloc, test_config, root_password);
return source;
}
test "login as root" {
const alloc = std.testing.allocator;
var arena = std.heap.ArenaAllocator.init(alloc);
defer arena.deinit();
var src = try makeApi(alloc);
std.debug.print("\npassword: {s}\n", .{root_password});
var api = try src.connectUnauthorized(cluster_host, arena.allocator());
defer api.close();
_ = try api.login("root", root_password);
}