Skip to content

Commit

Permalink
chore(sdk): updating cloud.bucket sdk tests (#2586)
Browse files Browse the repository at this point in the history
The SDK tests for `cloud.Bucket` are currently being ignored because they are not aligned to the new changes introduced by [v0.17.0](https://github.com/winglang/wing/releases/tag/v0.17.0) so I updated them. I also updated all the random test names so that they match the method they test.

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*.
  • Loading branch information
garysassano committed May 21, 2023
1 parent df70bd1 commit 62dabde
Show file tree
Hide file tree
Showing 23 changed files with 179 additions and 182 deletions.
5 changes: 2 additions & 3 deletions examples/tests/sdk_tests/bucket/put.w
Expand Up @@ -2,7 +2,7 @@ bring cloud;

let b = new cloud.Bucket();

new cloud.Function(inflight () => {
test "put" {
b.put("test1.txt", "Foo");
b.put("test2.txt", "Bar");

Expand All @@ -22,5 +22,4 @@ new cloud.Function(inflight () => {

let third = b.get("test2.txt");
assert(third == "Baz");

}) as "test:put";
}
6 changes: 2 additions & 4 deletions examples/tests/sdk_tests/bucket/put_json.w
Expand Up @@ -2,8 +2,7 @@ bring cloud;

let b = new cloud.Bucket();

new cloud.Function(inflight () => {

test "putJson" {
let jsonObj1 = Json { test: "test1" };
let jsonObj2 = Json { test: "test2" };

Expand All @@ -27,5 +26,4 @@ new cloud.Function(inflight () => {

assert(files.contains("test1.txt") == false);
assert(files.contains("test2.txt") == true);

}) as "test:putJson";
}
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/function/invoke.w
Expand Up @@ -7,7 +7,7 @@ let f = new cloud.Function(inflight ():str => {
});


test "function invoke" {
test "invoke" {
let x = f.invoke("");
assert(x == payload);
}
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/function/timeout.w
Expand Up @@ -19,7 +19,7 @@ let f = new cloud.Function(inflight () => {
}, cloud.FunctionProps {timeout: 1s});

// doesn't work yet- see issue: https://github.com/winglang/wing/issues/1980
test "function timeout" {
test "timeout" {
f.invoke("");
assert(c.peek() == 0);
}
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/queue/approx_size.w
Expand Up @@ -2,7 +2,7 @@ bring cloud;

let q = new cloud.Queue();

test "test" {
test "approxSize" {
assert(q.approxSize() == 0);
q.push("message");
assert(q.approxSize() == 1);
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/queue/pop.w
Expand Up @@ -4,7 +4,7 @@ let NIL = "<<NIL>>";

let q = new cloud.Queue();

test "test" {
test "pop" {
let msgs = ["Foo", "Bar"];
for msg in msgs {
q.push(msg);
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/queue/purge.w
Expand Up @@ -2,7 +2,7 @@ bring cloud;

let q = new cloud.Queue();

test "test" {
test "purge" {
q.push("foo");
q.push("bar");
q.push("baz");
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/queue/timeout.w
Expand Up @@ -19,7 +19,7 @@ q.addConsumer(inflight () => {


// TODO: this test fails sim due to issue: https://github.com/winglang/wing/issues/165
test "test" {
test "timeout" {
// each push should result in a timeout
q.push("foo");
q.push("foo");
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/table/list.w
Expand Up @@ -8,7 +8,7 @@ let table = new cloud.Table(
);


test "test" {
test "list" {
table.insert("eyal", Json { gender: "male" });
table.insert("revital", Json { gender: "female" });
let unorderded = MutJson {};
Expand Down
Expand Up @@ -40,7 +40,7 @@ module.exports = function({ q }) {
},
"output": {
"WING_TEST_RUNNER_FUNCTION_ARNS": {
"value": "[[\"root/Default/Default/test:test\",\"${aws_lambda_function.root_testtest_Handler_046C3415.arn}\"]]"
"value": "[[\"root/Default/Default/test:approxSize\",\"${aws_lambda_function.root_testapproxSize_Handler_D7563579.arn}\"]]"
}
},
"provider": {
Expand All @@ -50,61 +50,61 @@ module.exports = function({ q }) {
},
"resource": {
"aws_iam_role": {
"root_testtest_Handler_IamRole_6C1728D1": {
"root_testapproxSize_Handler_IamRole_03B77702": {
"//": {
"metadata": {
"path": "root/Default/Default/test:test/Handler/IamRole",
"uniqueId": "root_testtest_Handler_IamRole_6C1728D1"
"path": "root/Default/Default/test:approxSize/Handler/IamRole",
"uniqueId": "root_testapproxSize_Handler_IamRole_03B77702"
}
},
"assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}"
}
},
"aws_iam_role_policy": {
"root_testtest_Handler_IamRolePolicy_65A1D8BE": {
"root_testapproxSize_Handler_IamRolePolicy_EB9BA626": {
"//": {
"metadata": {
"path": "root/Default/Default/test:test/Handler/IamRolePolicy",
"uniqueId": "root_testtest_Handler_IamRolePolicy_65A1D8BE"
"path": "root/Default/Default/test:approxSize/Handler/IamRolePolicy",
"uniqueId": "root_testapproxSize_Handler_IamRolePolicy_EB9BA626"
}
},
"policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"sqs:SendMessage\"],\"Resource\":[\"${aws_sqs_queue.root_cloudQueue_E3597F7A.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"sqs:GetQueueAttributes\"],\"Resource\":[\"${aws_sqs_queue.root_cloudQueue_E3597F7A.arn}\"],\"Effect\":\"Allow\"}]}",
"role": "${aws_iam_role.root_testtest_Handler_IamRole_6C1728D1.name}"
"role": "${aws_iam_role.root_testapproxSize_Handler_IamRole_03B77702.name}"
}
},
"aws_iam_role_policy_attachment": {
"root_testtest_Handler_IamRolePolicyAttachment_3716AC26": {
"root_testapproxSize_Handler_IamRolePolicyAttachment_C558EB70": {
"//": {
"metadata": {
"path": "root/Default/Default/test:test/Handler/IamRolePolicyAttachment",
"uniqueId": "root_testtest_Handler_IamRolePolicyAttachment_3716AC26"
"path": "root/Default/Default/test:approxSize/Handler/IamRolePolicyAttachment",
"uniqueId": "root_testapproxSize_Handler_IamRolePolicyAttachment_C558EB70"
}
},
"policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
"role": "${aws_iam_role.root_testtest_Handler_IamRole_6C1728D1.name}"
"role": "${aws_iam_role.root_testapproxSize_Handler_IamRole_03B77702.name}"
}
},
"aws_lambda_function": {
"root_testtest_Handler_046C3415": {
"root_testapproxSize_Handler_D7563579": {
"//": {
"metadata": {
"path": "root/Default/Default/test:test/Handler/Default",
"uniqueId": "root_testtest_Handler_046C3415"
"path": "root/Default/Default/test:approxSize/Handler/Default",
"uniqueId": "root_testapproxSize_Handler_D7563579"
}
},
"environment": {
"variables": {
"QUEUE_URL_31e95cbd": "${aws_sqs_queue.root_cloudQueue_E3597F7A.url}",
"WING_FUNCTION_NAME": "Handler-c8f4f2a1"
"WING_FUNCTION_NAME": "Handler-c894e60c"
}
},
"function_name": "Handler-c8f4f2a1",
"function_name": "Handler-c894e60c",
"handler": "index.handler",
"publish": true,
"role": "${aws_iam_role.root_testtest_Handler_IamRole_6C1728D1.arn}",
"role": "${aws_iam_role.root_testapproxSize_Handler_IamRole_03B77702.arn}",
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.root_Code_02F3C603.bucket}",
"s3_key": "${aws_s3_object.root_testtest_Handler_S3Object_71CD07AC.key}",
"s3_key": "${aws_s3_object.root_testapproxSize_Handler_S3Object_4F41B3AF.key}",
"timeout": 30,
"vpc_config": {
"security_group_ids": [],
Expand All @@ -124,11 +124,11 @@ module.exports = function({ q }) {
}
},
"aws_s3_object": {
"root_testtest_Handler_S3Object_71CD07AC": {
"root_testapproxSize_Handler_S3Object_4F41B3AF": {
"//": {
"metadata": {
"path": "root/Default/Default/test:test/Handler/S3Object",
"uniqueId": "root_testtest_Handler_S3Object_71CD07AC"
"path": "root/Default/Default/test:approxSize/Handler/S3Object",
"uniqueId": "root_testapproxSize_Handler_S3Object_4F41B3AF"
}
},
"bucket": "${aws_s3_bucket.root_Code_02F3C603.bucket}",
Expand Down Expand Up @@ -197,7 +197,7 @@ class $Root extends $stdlib.std.Resource {
}
}
const q = this.node.root.newAbstract("@winglang/sdk.cloud.Queue",this,"cloud.Queue");
this.node.root.new("@winglang/sdk.cloud.Test",cloud.Test,this,"test:test",new $Inflight1(this,"$Inflight1"));
this.node.root.new("@winglang/sdk.cloud.Test",cloud.Test,this,"test:approxSize",new $Inflight1(this,"$Inflight1"));
}
}
class $App extends $AppBase {
Expand Down
Expand Up @@ -4,6 +4,6 @@
```log
- Compiling to sim...
✔ Compiling to sim...
pass ─ approx_size.wsim » root/env0/test:test
pass ─ approx_size.wsim » root/env0/test:approxSize
```

46 changes: 23 additions & 23 deletions tools/hangar/__snapshots__/test_corpus/invoke.w_compile_tf-aws.md
Expand Up @@ -56,7 +56,7 @@ module.exports = function({ f, payload }) {
},
"output": {
"WING_TEST_RUNNER_FUNCTION_ARNS": {
"value": "[[\"root/Default/Default/test:function invoke\",\"${aws_lambda_function.root_testfunctioninvoke_Handler_C57B9F76.arn}\"]]"
"value": "[[\"root/Default/Default/test:invoke\",\"${aws_lambda_function.root_testinvoke_Handler_EC5F6FA0.arn}\"]]"
}
},
"provider": {
Expand All @@ -75,11 +75,11 @@ module.exports = function({ f, payload }) {
},
"assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}"
},
"root_testfunctioninvoke_Handler_IamRole_83F46413": {
"root_testinvoke_Handler_IamRole_6E899BA4": {
"//": {
"metadata": {
"path": "root/Default/Default/test:function invoke/Handler/IamRole",
"uniqueId": "root_testfunctioninvoke_Handler_IamRole_83F46413"
"path": "root/Default/Default/test:invoke/Handler/IamRole",
"uniqueId": "root_testinvoke_Handler_IamRole_6E899BA4"
}
},
"assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}"
Expand All @@ -96,15 +96,15 @@ module.exports = function({ f, payload }) {
"policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}",
"role": "${aws_iam_role.root_cloudFunction_IamRole_DAEC3578.name}"
},
"root_testfunctioninvoke_Handler_IamRolePolicy_A7D5C925": {
"root_testinvoke_Handler_IamRolePolicy_33085D00": {
"//": {
"metadata": {
"path": "root/Default/Default/test:function invoke/Handler/IamRolePolicy",
"uniqueId": "root_testfunctioninvoke_Handler_IamRolePolicy_A7D5C925"
"path": "root/Default/Default/test:invoke/Handler/IamRolePolicy",
"uniqueId": "root_testinvoke_Handler_IamRolePolicy_33085D00"
}
},
"policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"lambda:InvokeFunction\"],\"Resource\":[\"${aws_lambda_function.root_cloudFunction_6A57BA0A.arn}\"],\"Effect\":\"Allow\"}]}",
"role": "${aws_iam_role.root_testfunctioninvoke_Handler_IamRole_83F46413.name}"
"role": "${aws_iam_role.root_testinvoke_Handler_IamRole_6E899BA4.name}"
}
},
"aws_iam_role_policy_attachment": {
Expand All @@ -118,15 +118,15 @@ module.exports = function({ f, payload }) {
"policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
"role": "${aws_iam_role.root_cloudFunction_IamRole_DAEC3578.name}"
},
"root_testfunctioninvoke_Handler_IamRolePolicyAttachment_ACF24EE5": {
"root_testinvoke_Handler_IamRolePolicyAttachment_130D08B6": {
"//": {
"metadata": {
"path": "root/Default/Default/test:function invoke/Handler/IamRolePolicyAttachment",
"uniqueId": "root_testfunctioninvoke_Handler_IamRolePolicyAttachment_ACF24EE5"
"path": "root/Default/Default/test:invoke/Handler/IamRolePolicyAttachment",
"uniqueId": "root_testinvoke_Handler_IamRolePolicyAttachment_130D08B6"
}
},
"policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
"role": "${aws_iam_role.root_testfunctioninvoke_Handler_IamRole_83F46413.name}"
"role": "${aws_iam_role.root_testinvoke_Handler_IamRole_6E899BA4.name}"
}
},
"aws_lambda_function": {
Expand Down Expand Up @@ -155,26 +155,26 @@ module.exports = function({ f, payload }) {
"subnet_ids": []
}
},
"root_testfunctioninvoke_Handler_C57B9F76": {
"root_testinvoke_Handler_EC5F6FA0": {
"//": {
"metadata": {
"path": "root/Default/Default/test:function invoke/Handler/Default",
"uniqueId": "root_testfunctioninvoke_Handler_C57B9F76"
"path": "root/Default/Default/test:invoke/Handler/Default",
"uniqueId": "root_testinvoke_Handler_EC5F6FA0"
}
},
"environment": {
"variables": {
"FUNCTION_NAME_5bb84dfa": "${aws_lambda_function.root_cloudFunction_6A57BA0A.arn}",
"WING_FUNCTION_NAME": "Handler-c86a022c"
"WING_FUNCTION_NAME": "Handler-c8031175"
}
},
"function_name": "Handler-c86a022c",
"function_name": "Handler-c8031175",
"handler": "index.handler",
"publish": true,
"role": "${aws_iam_role.root_testfunctioninvoke_Handler_IamRole_83F46413.arn}",
"role": "${aws_iam_role.root_testinvoke_Handler_IamRole_6E899BA4.arn}",
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.root_Code_02F3C603.bucket}",
"s3_key": "${aws_s3_object.root_testfunctioninvoke_Handler_S3Object_7E2BB2CC.key}",
"s3_key": "${aws_s3_object.root_testinvoke_Handler_S3Object_4594037E.key}",
"timeout": 30,
"vpc_config": {
"security_group_ids": [],
Expand Down Expand Up @@ -205,11 +205,11 @@ module.exports = function({ f, payload }) {
"key": "<ASSET_KEY>",
"source": "<ASSET_SOURCE>"
},
"root_testfunctioninvoke_Handler_S3Object_7E2BB2CC": {
"root_testinvoke_Handler_S3Object_4594037E": {
"//": {
"metadata": {
"path": "root/Default/Default/test:function invoke/Handler/S3Object",
"uniqueId": "root_testfunctioninvoke_Handler_S3Object_7E2BB2CC"
"path": "root/Default/Default/test:invoke/Handler/S3Object",
"uniqueId": "root_testinvoke_Handler_S3Object_4594037E"
}
},
"bucket": "${aws_s3_bucket.root_Code_02F3C603.bucket}",
Expand Down Expand Up @@ -306,7 +306,7 @@ class $Root extends $stdlib.std.Resource {
}
const payload = "hello";
const f = this.node.root.newAbstract("@winglang/sdk.cloud.Function",this,"cloud.Function",new $Inflight1(this,"$Inflight1"));
this.node.root.new("@winglang/sdk.cloud.Test",cloud.Test,this,"test:function invoke",new $Inflight2(this,"$Inflight2"));
this.node.root.new("@winglang/sdk.cloud.Test",cloud.Test,this,"test:invoke",new $Inflight2(this,"$Inflight2"));
}
}
class $App extends $AppBase {
Expand Down
Expand Up @@ -4,6 +4,6 @@
```log
- Compiling to sim...
✔ Compiling to sim...
pass ─ invoke.wsim » root/env0/test:function invoke
pass ─ invoke.wsim » root/env0/test:invoke
```

0 comments on commit 62dabde

Please sign in to comment.