Skip to content

Commit 8cd9c93

Browse files
authored
Updating all packages at the same time and pinning the broken @aws-cd… (#2025)
…k/cloud-assembly-schema
1 parent a49210d commit 8cd9c93

File tree

4 files changed

+64
-39
lines changed

4 files changed

+64
-39
lines changed

aws-ts-nextjs/demoapp/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
"react": "18.3.1",
2121
"react-dom": "18.3.1",
2222
"tailwindcss": "3.4.17",
23-
"typescript": "5.1.6"
23+
"typescript": "5.1.6",
24+
"@aws-cdk/cloud-assembly-schema": "40.0.7"
2425
},
2526
"devDependencies": {
2627
"sst": "3.9.8",
2728
"aws-cdk-lib": "2.179.0",
2829
"constructs": "10.4.2"
2930
}
30-
}
31+
}

testing-unit-cs-mocks/Testing.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,51 @@ class Mocks : IMocks
1313
public Task<(string? id, object state)> NewResourceAsync(MockResourceArgs args)
1414
{
1515
var outputs = ImmutableDictionary.CreateBuilder<string, object>();
16-
16+
1717
// Forward all input parameters as resource outputs, so that we could test them.
18-
outputs.AddRange(args.Inputs);
19-
18+
if (args.Inputs != null)
19+
{
20+
outputs.AddRange(args.Inputs);
21+
}
22+
2023
// Set the name to resource name if it's not set explicitly in inputs.
21-
if (!args.Inputs.ContainsKey("name"))
24+
if (args.Inputs?.ContainsKey("name") != true && args.Name != null)
25+
{
2226
outputs.Add("name", args.Name);
23-
27+
}
28+
2429
if (args.Type == "azure-native:storage:Blob")
2530
{
2631
// Assets can't directly go through the engine.
2732
// We don't need them in the test, so blank out the property for now.
2833
outputs.Remove("source");
2934
}
30-
35+
3136
// For a Storage Account...
32-
if (args.Type == "azure-native:storage:StorageAccount")
37+
if (args.Type == "azure-native:storage:StorageAccount" && args.Name != null)
3338
{
3439
// ... set its web endpoint property.
35-
// Normally this would be calculated by Azure, so we have to mock it.
36-
outputs.Add("primaryEndpoints", new Dictionary<string, string>
37-
{
38-
{ "web", $"https://{args.Name}.web.core.windows.net" },
39-
}.ToImmutableDictionary());
40+
// Normally this would be calculated by Azure, so we have to mock it.
41+
var endpoints = new Dictionary<string, string>
42+
{
43+
{ "web", $"https://{args.Name}.web.core.windows.net" }
44+
};
45+
outputs.Add("primaryEndpoints", endpoints.ToImmutableDictionary());
4046
}
4147

4248
// Default the resource ID to `{name}_id`.
43-
// We could also format it as `/subscription/abc/resourceGroups/xyz/...` if that was important for tests.
44-
args.Id ??= $"{args.Name}_id";
45-
return Task.FromResult((args.Id, (object)outputs));
49+
args.Id ??= args.Name != null ? $"{args.Name}_id" : "unknown_id";
50+
return Task.FromResult((args.Id, (object)outputs.ToImmutable()));
4651
}
47-
52+
4853
public Task<object> CallAsync(MockCallArgs args)
4954
{
5055
// We don't use this method in this particular test suite.
5156
// Default to returning whatever we got as input.
5257
return Task.FromResult((object)args.Args);
5358
}
5459
}
55-
60+
5661
public static class TestingExtensions
5762
{
5863
/// <summary>

testing-unit-fs-mocks/UnitTestingFs.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="FluentAssertions" Version="8.0.1" />
10+
<PackageReference Include="FluentAssertions" Version="5.10.3" />
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
1212
<PackageReference Include="NUnit" Version="3.14.0" />
1313
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />

testing-unit-fs-mocks/WebsiteStackTests.fs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace UnitTesting
44

55
open System
66
open System.Collections.Immutable
7+
open System.Collections.Generic
78
open System.Threading.Tasks
89
open NUnit.Framework
910
open Pulumi
@@ -14,52 +15,70 @@ open FluentAssertions
1415

1516
[<TestFixture>]
1617
type WebserverStackTests() =
17-
let runTest(): ImmutableArray<Resource> =
18+
let runTest () : ImmutableArray<Resource> =
1819
let options = new TestOptions(IsPreview = Nullable<bool> false)
20+
1921
Deployment.TestAsync<WebsiteStack>(new Mocks(), options)
2022
|> Async.AwaitTask
2123
|> Async.RunSynchronously
22-
23-
let getValue(output: Output<'a>): 'a =
24+
25+
let getValue (output: Output<'a>) : 'a =
2426
let tcs = new TaskCompletionSource<'a>()
25-
output.Apply(fun v -> tcs.SetResult(v); v) |> ignore
27+
28+
output.Apply(fun v ->
29+
tcs.SetResult(v)
30+
v)
31+
|> ignore
32+
2633
tcs.Task.Result
2734

2835
[<Test>]
2936
member this.SingleResourceGroupExists() =
30-
let resources = runTest()
37+
let resources = runTest ()
3138

3239
let resourceGroupCount = resources.OfType<ResourceGroup>() |> Seq.length
33-
resourceGroupCount.Should().Be(1, "a single resource group is expected") |> ignore
40+
41+
(resourceGroupCount :> obj).Should().Be(1, "a single resource group is expected")
42+
|> ignore
3443

3544
[<Test>]
3645
member this.ResourceGroupHasEnvironmentTag() =
37-
let resources = runTest()
46+
let resources = runTest ()
3847
let resourceGroup = resources.OfType<ResourceGroup>() |> Seq.head
3948

4049
let tags = getValue resourceGroup.Tags
41-
tags.Should().NotBeNull("Tags must be defined") |> ignore
42-
tags.Should().ContainKey("Environment", null) |> ignore
50+
51+
(tags :> obj).Should().NotBeNull("Tags must be defined")
52+
|> ignore
53+
54+
(tags :> System.Collections.Generic.IDictionary<string, string>).Should().ContainKey("Environment", null)
55+
|> ignore
4356

4457
[<Test>]
4558
member this.StorageAccountBelongsToResourceGroup() =
46-
let resources = runTest()
59+
let resources = runTest ()
4760
let storageAccount = resources.OfType<Account>() |> Seq.tryHead |> Option.toObj
48-
storageAccount.Should().NotBeNull("Storage account not found") |> ignore
49-
61+
62+
(storageAccount :> obj).Should().NotBeNull("Storage account not found")
63+
|> ignore
64+
5065
let resourceGroupName = getValue storageAccount.ResourceGroupName
51-
resourceGroupName.Should().Be("www-prod-rg", null) |> ignore
66+
(resourceGroupName :> obj).Should().Be("www-prod-rg", null) |> ignore
5267

5368
[<Test>]
5469
member this.UploadsTwoFiles() =
55-
let resources = runTest()
70+
let resources = runTest ()
5671
let filesCount = resources.OfType<Blob>() |> Seq.length
57-
filesCount.Should().Be(2, "Should have uploaded files from `wwwroot`") |> ignore
58-
72+
73+
(filesCount :> obj).Should().Be(2, "Should have uploaded files from `wwwroot`")
74+
|> ignore
75+
5976
[<Test>]
6077
member this.StackExportsWebsiteUrl() =
61-
let resources = runTest()
78+
let resources = runTest ()
6279
let stack = resources.OfType<WebsiteStack>() |> Seq.head
63-
80+
6481
let endpoint = getValue stack.Endpoint
65-
endpoint.Should().Be("https://wwwprodsa.web.core.windows.net", null) |> ignore
82+
83+
(endpoint :> obj).Should().Be("https://wwwprodsa.web.core.windows.net", null)
84+
|> ignore

0 commit comments

Comments
 (0)