echoing-address-44214
03/21/2023, 2:52 AMconst password = new random.RandomPassword(
props.name + "-redis-auth-token",
{
length: 50,
special: true,
overrideSpecial: "!&#$^<>-",
},
{ parent: this, ...opts }
);
new aws.secretsmanager.SecretVersion(
props.name + "-redis-secret-version",
{
secretId: secret.id,
secretString: password.result,
},
{ parent: this, ...opts }
);
From my tests:
const parametersCaptured = new Map<string, any>();
beforeAll(() => {
pulumi.runtime.setMocks(
{
newResource: function (args: pulumi.runtime.MockResourceArgs): {
id: string;
state: any;
} {
switch (args.type) {
case "random:index/randomPassword:RandomPassword":
parametersCaptured.set(args.type, args.inputs);
return {
id: args.inputs.name + "_id",
state: {
result: "myseeminlyrandomtestpassword",
...args.inputs,
},
};
default:
parametersCaptured.set(args.type, args.inputs);
return {
id: args.inputs.name + "_id",
state: {
...args.inputs,
},
};
}
},
[...]
// inside a pulumi.all...
expect(
parametersCaptured.get(
"aws:secretsmanager/secretVersion:SecretVersion"
)
).toStrictEqual({
secretId: `${expectedGroupId}_id`,
secretString: "myseeminlyrandomtestpassword",
});
I get the error:
Object {
"secretId": "unit-test-prefix-my-test-cluster_id",
- "secretString": "myseeminlyrandomtestpassword",
+ "secretString": Object {
+ "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270",
+ "value": "myseeminlyrandomtestpassword",
+ },
}
Why is secretString an object? And what is "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270"? I would expect secretString to just be equal to myseeminlyrandomtestpassword. This way of testing works for other resources.steep-toddler-94095
03/21/2023, 4:05 AMechoing-address-44214
03/21/2023, 4:06 AM