Create integration test
This commit is contained in:
parent
6e2754225f
commit
8763132d35
5 changed files with 87 additions and 20 deletions
36
tests/api_integration/lib.zig
Normal file
36
tests/api_integration/lib.zig
Normal file
|
@ -0,0 +1,36 @@
|
|||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue