Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit af30208

Browse files
committed
test: refacto test
1 parent ed7ae07 commit af30208

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/tests.zig

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ pub fn onRequestConnect(ctx: *Ctx, res: anyerror!void) anyerror!void {
3838
}
3939

4040
test "example.com" {
41-
// const url = "http://127.0.0.1:8080";
42-
const url = "https://www.example.com";
41+
var urls = [_][]const u8{
42+
"https://www.example.com",
43+
};
44+
try do(&urls);
45+
}
4346

47+
fn do(urls: [][]const u8) !void {
4448
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
4549
defer switch (gpa.deinit()) {
4650
.ok => {},
@@ -64,13 +68,16 @@ test "example.com" {
6468

6569
var server_header_buffer: [1024 * 1024]u8 = undefined;
6670

67-
try client.async_open(
68-
.GET,
69-
try std.Uri.parse(url),
70-
.{ .server_header_buffer = &server_header_buffer },
71-
&ctx,
72-
onRequestConnect,
73-
);
71+
for (urls) |url| {
72+
std.log.info("request {s}", .{url});
73+
try client.async_open(
74+
.GET,
75+
try std.Uri.parse(url),
76+
.{ .server_header_buffer = &server_header_buffer },
77+
&ctx,
78+
onRequestConnect,
79+
);
7480

75-
try std.testing.expect(ctx.err == null);
81+
try std.testing.expect(ctx.err == null);
82+
}
7683
}

0 commit comments

Comments
 (0)