From 483487103de5a2e4b8de58171b154b0ae1ab23e8 Mon Sep 17 00:00:00 2001
From: Tsuf Cohen <39455181+tsuf239@users.noreply.github.com>
Date: Thu, 18 Jul 2024 21:25:20 +0300
Subject: [PATCH 1/2] fix: fix gcp function tests (#6927)
## Checklist
- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing
*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
---
docs/api/04-standard-library/std/resource.md | 2 +-
examples/tests/sdk_tests/function/aws-function.test.w | 4 ++--
libs/wingsdk/src/shared-gcp/function.inflight.ts | 3 ++-
.../sdk_tests/function/aws-function.test.w_test_sim.md | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/docs/api/04-standard-library/std/resource.md b/docs/api/04-standard-library/std/resource.md
index 2e2e69b0e6b..df81ad06ecc 100644
--- a/docs/api/04-standard-library/std/resource.md
+++ b/docs/api/04-standard-library/std/resource.md
@@ -120,7 +120,7 @@ Operations to lift on the object.
- *Extends:* ILiftable
-- *Implemented By:* BucketRef, Domain, FunctionRef, QueueRef, SecretRef, Api, Bucket, Counter, Domain, Endpoint, Function, OnDeploy, Queue, Schedule, Secret, Service, Topic, Website, Redis, Table, Container, Policy, Resource, State, AutoIdResource, Resource, Test, TestRunner, Button, Field, FileBrowser, HttpClient, Section, ValueField, VisualComponent, IAwsFunction, IAwsInflightHost, IApiEndpointHandler, IBucketEventHandler, IFunctionHandler, IOnDeployHandler, IQueueSetConsumerHandler, IScheduleOnTickHandler, IServiceHandler, IServiceStopHandler, ITopicOnMessageHandler, IResourceFactory, ISimulatorInflightHost, ISimulatorResource, IHostedLiftable, IInflight, IInflightHost, IResource, ITestHandler, IButtonHandler, IFieldHandler, IFileBrowserDeleteHandler, IFileBrowserGetHandler, IFileBrowserListHandler, IFileBrowserPutHandler, IHttpClientGetApiSpecHandler, IHttpClientGetUrlHandler, IPredicateHandler
+- *Implemented By:* BucketRef, Domain, FunctionRef, QueueRef, SecretRef, Api, Bucket, Counter, Domain, Endpoint, Function, OnDeploy, Queue, Schedule, Secret, Service, Topic, Website, Container, Policy, Resource, State, AutoIdResource, Resource, Test, TestRunner, Button, Field, FileBrowser, HttpClient, Section, ValueField, VisualComponent, IAwsFunction, IAwsInflightHost, IApiEndpointHandler, IBucketEventHandler, IFunctionHandler, IOnDeployHandler, IQueueSetConsumerHandler, IScheduleOnTickHandler, IServiceHandler, IServiceStopHandler, ITopicOnMessageHandler, IResourceFactory, ISimulatorInflightHost, ISimulatorResource, IHostedLiftable, IInflight, IInflightHost, IResource, ITestHandler, IButtonHandler, IFieldHandler, IFileBrowserDeleteHandler, IFileBrowserGetHandler, IFileBrowserListHandler, IFileBrowserPutHandler, IHttpClientGetApiSpecHandler, IHttpClientGetUrlHandler, IPredicateHandler
A liftable object that needs to be registered on the host as part of the lifting process.
diff --git a/examples/tests/sdk_tests/function/aws-function.test.w b/examples/tests/sdk_tests/function/aws-function.test.w
index 1da2ac9c8dd..c78b8d2a09a 100644
--- a/examples/tests/sdk_tests/function/aws-function.test.w
+++ b/examples/tests/sdk_tests/function/aws-function.test.w
@@ -37,7 +37,7 @@ let fn = new cloud.Function(inflight (msg: Json?) => {
let fnInfo = getFunctionInfo(fn);
-test "AWS Function" {
+new std.Test(inflight () => {
if let info = fnInfo {
if target == "tf-aws" {
assert(info.get("functionArn").contains("arn:aws:lambda:"));
@@ -73,4 +73,4 @@ test "AWS Function" {
msg = err;
}
expect.ok(msg.contains("fake error"), "Expected fake error message");
-}
+}, timeout: 3m) as "AWS Function";
diff --git a/libs/wingsdk/src/shared-gcp/function.inflight.ts b/libs/wingsdk/src/shared-gcp/function.inflight.ts
index e53c4f5bc7f..d2655f0cef1 100644
--- a/libs/wingsdk/src/shared-gcp/function.inflight.ts
+++ b/libs/wingsdk/src/shared-gcp/function.inflight.ts
@@ -65,7 +65,8 @@ export class FunctionClient implements IFunctionClient {
},
},
});
- return (res.data as Json | undefined) ?? undefined;
+ /// The gcp call returns "" even for an undefined call
+ return (res.data as undefined | Json) || undefined;
} catch (error) {
throw new Error(
`Error while invoking the function ${this.functionName}:\n${
diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md
index 2f9b4ca05a9..5c03d3c231d 100644
--- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md
+++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md
@@ -2,7 +2,7 @@
## stdout.log
```log
-pass โ aws-function.test.wsim ยป root/env0/test:AWS Function
+pass โ aws-function.test.wsim ยป root/env0/AWS Function
Tests 1 passed (1)
Snapshots 1 skipped
From c94661c77c85cf0441de1b5fead14046b55dcbd1 Mon Sep 17 00:00:00 2001
From: Tsuf Cohen <39455181+tsuf239@users.noreply.github.com>
Date: Sun, 21 Jul 2024 14:15:23 +0300
Subject: [PATCH 2/2] fix(compiler): optional macro chaining (#6659)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
closes [#4470](https://github.com/winglang/wing/issues/4470)
closes [#6662](https://github.com/winglang/wing/issues/6662) as well! ๐
I inserted a default value for optional maps, json, sets, and structs
below you can find the compilation output of the following wing code, comments and newlines added later and not a part of the original compilation output.
```wing
struct Result {
item: Json?;
items: Array?;
mapItem: Map?;
mapItems: Array