add tests for config based on header and path

This commit is contained in:
Emil Lerch 2023-05-30 16:30:58 -07:00
parent 08141a7bed
commit 327ebae4f2
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
2 changed files with 14 additions and 0 deletions

View File

@ -6,3 +6,4 @@
/c = zig-out/lib/libfaas-proxy-sample-lib-in-c.so /c = zig-out/lib/libfaas-proxy-sample-lib-in-c.so
/ = zig-out/lib/libfaas-proxy-sample-lib.so / = zig-out/lib/libfaas-proxy-sample-lib.so
Host: iam.aws.lerch.org / = zig-out/lib/libfaas-proxy-sample-lib.so

View File

@ -462,6 +462,13 @@ fn testGet(comptime path: []const u8) !void {
"\r\n"); "\r\n");
} }
fn testHostGet(comptime host: []const u8, comptime path: []const u8) !void {
try testRequest("GET " ++ path ++ " HTTP/1.1\r\n" ++
"Host: " ++ host ++ "\r\n" ++
"Accept: */*\r\n" ++
"\r\n");
}
test { test {
// To run nested container tests, either, call `refAllDecls` which will // To run nested container tests, either, call `refAllDecls` which will
// reference all declarations located in the given argument. // reference all declarations located in the given argument.
@ -480,3 +487,9 @@ test "root path get" {
try std.testing.expectEqual(@as(usize, 2), test_resp_buf_len); try std.testing.expectEqual(@as(usize, 2), test_resp_buf_len);
try std.testing.expectEqualStrings(" 1", test_resp_buf[0..test_resp_buf_len]); try std.testing.expectEqualStrings(" 1", test_resp_buf[0..test_resp_buf_len]);
} }
test "root path, alternative host get" {
std.testing.log_level = .debug;
log.debug("", .{});
try testHostGet("iam.aws.lerch.org", "/");
try std.testing.expectEqualStrings("iam response", test_resp_buf[0..test_resp_buf_len]);
}