-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_test.zig
More file actions
39 lines (28 loc) · 1.24 KB
/
Copy pathsimple_test.zig
File metadata and controls
39 lines (28 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const std = @import("std");
const testing = std.testing;
const c = @cImport({
@cInclude("libcouchbase/couchbase.h");
});
test "simple connection" {
std.debug.print("\n=== Starting simple connection test ===\n", .{});
var create_opts: ?*c.lcb_CREATEOPTS = null;
_ = c.lcb_createopts_create(&create_opts, c.LCB_TYPE_BUCKET);
defer _ = c.lcb_createopts_destroy(create_opts);
std.debug.print("1. Created opts\n", .{});
const conn_str = "couchbase://127.0.0.1";
_ = c.lcb_createopts_connstr(create_opts, conn_str.ptr, conn_str.len);
std.debug.print("2. Set connection string\n", .{});
const username = "tester";
const password = "csfb2010";
_ = c.lcb_createopts_credentials(create_opts, username.ptr, username.len, password.ptr, password.len);
std.debug.print("3. Set credentials\n", .{});
var instance: ?*c.lcb_INSTANCE = null;
const rc = c.lcb_create(&instance, create_opts);
std.debug.print("4. Create result: {d}\n", .{rc});
if (instance) |inst| {
std.debug.print("5. Destroying instance\n", .{});
c.lcb_destroy(inst);
std.debug.print("6. Instance destroyed\n", .{});
}
std.debug.print("=== Test completed ===\n", .{});
}