Skip to content

Commit

Permalink
CI: try run async unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Oct 28, 2024
1 parent 5aaecf1 commit 3119fc7
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions bindings/zig/src/opendal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -422,28 +422,28 @@ test "operator advanced operations" {
}

// TODO: test async operations - crash application
// test "async operations" {
// const coro = @import("libcoro");
//
// const allocator = std.testing.allocator;
// const stack = try coro.stackAlloc(allocator, null);
// defer allocator.free(stack);
test "async operations" {
const coro = @import("libcoro");

// var op = try Operator.init("memory", null);
// defer op.deinit();
const allocator = std.testing.allocator;
const stack = try coro.stackAlloc(allocator, null);
defer allocator.free(stack);

// const data = "hello world";
var op = try Operator.init("memory", null);
defer op.deinit();

// const write_frame = try coro.xasync(writeData, .{ &op, "/test", data }, stack);
// defer write_frame.deinit();
const data = "hello world";

// const read_frame = try coro.xasync(readData, .{ &op, "/test" }, stack);
// defer read_frame.deinit();
const write_frame = try coro.xasync(writeData, .{ &op, "/test", data }, stack);
defer write_frame.deinit();

// try coro.xawait(write_frame);
// const read_bytes = try coro.xawait(read_frame);
// try testing.expectEqualStrings(read_bytes, data);
// }
const read_frame = try coro.xasync(readData, .{ &op, "/test" }, stack);
defer read_frame.deinit();

try coro.xawait(write_frame);
const read_bytes = try coro.xawait(read_frame);
try testing.expectEqualStrings(read_bytes, data);
}

fn writeData(op: *Operator, path: []const u8, data: []const u8) anyerror!void {
try op.write(path, data);
Expand Down

0 comments on commit 3119fc7

Please sign in to comment.