worried-knife-31967
03/11/2021, 11:24 AMvar frontdoor = resources.OfType<Frontdoor>().FirstOrDefault();
var pools = frontdoor.BackendPools;
Therefore I'm not sure how to access the ImmutableArray on that to check the sizevar frontdoor = resources.OfType<Frontdoor>().FirstOrDefault();
var backendPoolCount = 0;
frontdoor.BackendPools.Apply(bp => {
backendPoolCount = bp.Count();
return false;
});
backendPoolCount.ShouldBe(1);
}
which just feels dirty...tall-librarian-49374
03/11/2021, 1:29 PMworried-knife-31967
03/11/2021, 1:54 PMlittle-cartoon-10569
03/11/2021, 8:01 PMApply()
would happen asynchronously, and almost certainly after the ShouldBe()
.bored-oyster-3147
03/11/2021, 8:14 PM.Apply
to work for himlittle-cartoon-10569
03/11/2021, 8:17 PMbored-oyster-3147
03/11/2021, 8:18 PMlittle-cartoon-10569
03/11/2021, 8:20 PM[TestMethod]
public async Task CorrectlyFailingTest()
{
var frontdoor = resources.OfType<Frontdoor>().FirstOrDefault();
(await frontdoor.BackendPools.Apply(bp => {
return bp.Count();
})).GetValueAsync().ShouldBe(1);
}
GetValueAsync()
. Good stuff. Updated previous comment.bored-oyster-3147
03/11/2021, 8:29 PMvar backendPools = await frontdoor.BackendPools.GetValueAsync();
var backendPoolCount = backendPools.Count();
little-cartoon-10569
03/11/2021, 8:32 PMtall-librarian-49374
03/11/2021, 8:52 PMconst promise = <T>(output: pulumi.Output<T>): Promise<T | undefined> =>
(output as any).promise() as Promise<T>;
it("should have a tag:key Name", async () => {
const tags = await promise(vpc.tags);
expect(tags).to.include.keys("Name");
expect(tags?.Name).to.equal("my_app");
});
little-cartoon-10569
03/11/2021, 9:11 PMconst promise = <T>(output: pulumi.Output<T>): Promise<T | undefined> =>
(output as any).promise() as Promise<T>;
it("should have a tag:key Name", async () => {
expect(vpc.tags).to.eventually.include.keys("Name");
expect(vpc.tags?.Name).to.eventually.equal("my_app");
});
const promise = <T>(output: pulumi.Output<T>): Promise<T | undefined> =>
it("should have a tag:key Name", async () => {
expect(vpc.tags.getAsyncValue()).to.include.keys("Name");
expect(vpc.tags?.Name.getAsyncValue()).to.equal("my_app");
});
Or even expectAsync(vpc.tags).to.include.keys("Name")
.. tidier still.