microscopic-dress-1605
03/09/2021, 8:38 AMaws.iam.getPolicyDocument
.
However, I’ve noticed that getPolicyDocument
gets mocked away during unit testing.
As a result: GetPolicyDocumentResult.json
returns undefined in the unit test 😒
Of course I can add something like this in Mocks.call
:
pulumi.runtime.setMocks({
newResource: function(resourceType: string, name: string, inputs: any, provider?: string, id?: string) {},
call: function(token: string, args: any, provider?: string) {
switch (token) {
case 'aws:iam/getPolicyDocument:getPolicyDocument':
return {
json: JSON.stringify(args),
};
}
return args;
},
});
But then the returned IAM Policy json document is not a valid IAM policy.
What would be the preferred way of unit testing the result of getPolicyDocument
? Thank you for your input.
As you see the code is written in Typescript.little-cartoon-10569
03/09/2021, 7:47 PMmicroscopic-dress-1605
03/09/2021, 7:52 PMgetPolicyDocument
.little-cartoon-10569
03/09/2021, 7:52 PMmicroscopic-dress-1605
03/09/2021, 7:53 PM