diff --git a/src/aws.zig b/src/aws.zig index c3ca53b..08ac473 100644 --- a/src/aws.zig +++ b/src/aws.zig @@ -1785,3 +1785,33 @@ test "rest_json_1_query_no_input: lambda listFunctions runtime" { call.response.functions.?[12].function_name.?, ); } +test "rest_json_1_work_with_lambda: lambda multiple functions (blank test)" { + // Replicating this test would not provide additional coverage. It is + // here for completeness only +} +test "ec2_query_no_input: EC2 describe regions" { + const allocator = std.testing.allocator; + var test_harness = TestSetup.init(allocator, .{ + .allocator = allocator, + .server_response = @embedFile("test_ec2_query_no_input.response"), + .server_response_headers = @constCast(&[_][2][]const u8{ + .{ "Content-Type", "text/xml;charset=UTF-8" }, + .{ "x-amzn-RequestId", "4cdbdd69-800c-49b5-8474-ae4c17709782" }, + }), + }); + defer test_harness.deinit(); + const options = try test_harness.start(); + const ec2 = (Services(.{.ec2}){}).ec2; + const call = try test_harness.client.call(ec2.describe_regions.Request{}, options); + defer call.deinit(); + test_harness.stop(); + // Request expectations + try std.testing.expectEqual(std.http.Method.POST, test_harness.request_options.request_method); + try std.testing.expectEqualStrings("/?Action=DescribeRegions&Version=2016-11-15", test_harness.request_options.request_target); + try std.testing.expectEqualStrings( + \\Action=DescribeRegions&Version=2016-11-15 + , test_harness.request_options.request_body); + // Response expectations + try std.testing.expectEqualStrings("4cdbdd69-800c-49b5-8474-ae4c17709782", call.response_metadata.request_id); + try std.testing.expectEqual(@as(usize, 17), call.response.regions.?.len); +} diff --git a/src/main.zig b/src/main.zig index f962127..4df1244 100644 --- a/src/main.zig +++ b/src/main.zig @@ -137,8 +137,6 @@ pub fn main() anyerror!void { std.log.info("request id: {any}", .{call.response_metadata.request_id}); std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0}); }, - // ^^ under test. vv stil in progress - // This has an issue with json.zig .rest_json_1_query_with_input => { const call = try client.call(services.lambda.list_functions.Request{ .max_items = 1, @@ -147,7 +145,6 @@ pub fn main() anyerror!void { std.log.info("request id: {any}", .{call.response_metadata.request_id}); std.log.info("account has functions: {}", .{call.response.functions.?.len > 0}); }, - // This is skipped .rest_json_1_query_no_input => { const call = try client.call(services.lambda.list_functions.Request{}, options); defer call.deinit(); @@ -183,15 +180,14 @@ pub fn main() anyerror!void { } }, .ec2_query_no_input => { - std.log.err("EC2 functions not yet working in 0.11", .{}); - // // Describe regions is a simpler request and easier to debug + // Describe regions is a simpler request and easier to debug const result = try client.call(services.ec2.describe_regions.Request{}, options); defer result.deinit(); std.log.info("request id: {any}", .{result.response_metadata.request_id}); std.log.info("region count: {d}", .{result.response.regions.?.len}); }, + // ^^ under test. vv still in progress .ec2_query_with_input => { - std.log.err("EC2 functions not yet working in 0.11", .{}); // Describe instances is more interesting const result = try client.call(services.ec2.describe_instances.Request{ .max_results = 6 }, options); defer result.deinit(); diff --git a/src/test_ec2_query_no_input.response b/src/test_ec2_query_no_input.response new file mode 100644 index 0000000..c766bad --- /dev/null +++ b/src/test_ec2_query_no_input.response @@ -0,0 +1,91 @@ + + + 4cdbdd69-800c-49b5-8474-ae4c17709782 + + + ap-south-1 + ec2.ap-south-1.amazonaws.com + opt-in-not-required + + + eu-north-1 + ec2.eu-north-1.amazonaws.com + opt-in-not-required + + + eu-west-3 + ec2.eu-west-3.amazonaws.com + opt-in-not-required + + + eu-west-2 + ec2.eu-west-2.amazonaws.com + opt-in-not-required + + + eu-west-1 + ec2.eu-west-1.amazonaws.com + opt-in-not-required + + + ap-northeast-3 + ec2.ap-northeast-3.amazonaws.com + opt-in-not-required + + + ap-northeast-2 + ec2.ap-northeast-2.amazonaws.com + opt-in-not-required + + + ap-northeast-1 + ec2.ap-northeast-1.amazonaws.com + opt-in-not-required + + + ca-central-1 + ec2.ca-central-1.amazonaws.com + opt-in-not-required + + + sa-east-1 + ec2.sa-east-1.amazonaws.com + opt-in-not-required + + + ap-southeast-1 + ec2.ap-southeast-1.amazonaws.com + opt-in-not-required + + + ap-southeast-2 + ec2.ap-southeast-2.amazonaws.com + opt-in-not-required + + + eu-central-1 + ec2.eu-central-1.amazonaws.com + opt-in-not-required + + + us-east-1 + ec2.us-east-1.amazonaws.com + opt-in-not-required + + + us-east-2 + ec2.us-east-2.amazonaws.com + opt-in-not-required + + + us-west-1 + ec2.us-west-1.amazonaws.com + opt-in-not-required + + + us-west-2 + ec2.us-west-2.amazonaws.com + opt-in-not-required + + +