Another migration question, updating to Pulumi 3.0...
# dotnet
m
Another migration question, updating to Pulumi 3.0 has broken our unit testing mock, the example here seems to have been updated to fix the breaking change, but it doesn't work https://www.pulumi.com/docs/guides/testing/unit/#add-mocks it complains about args not existing, are there any working examples to update the RunAsync method? It also looks like the full code example here https://github.com/pulumi/examples/tree/74db62a03d013c2854d2cf933c074ea0a3bbf69d/testing-unit-cs has not been updated
t
Thank you for reporting this! The example should be something like
Copy code
public static class Testing
{
    public static Task<ImmutableArray<Resource>> RunAsync<T>() where T : Stack, new()
    {
        var mocks = new Mock<IMocks>();
        mocks.Setup(m => m.NewResourceAsync(It.IsAny<MockResourceArgs>()))
            .ReturnsAsync((MockResourceArgs args) => (args.Id, args.Inputs));
        mocks.Setup(m => m.CallAsync(It.IsAny<MockCallArgs>()))
            .ReturnsAsync((MockCallArgs args) => args.Args);
        return Deployment.TestAsync<T>(mocks.Object, new TestOptions { IsPreview = false });
    }
}
If this works for you, I will open a PR for docs
m
So it sort of works, it does return the resource properties, but the resource name is null
Thats the actual Azure resource name property, not the Pulumi resource name
t
I guess you’d need to set it manually in the callback. Was it working in 2.0?
m
Yeah it was
t
Which resources are you testing? Azure Native? Was it also Azure Native in 2.0?