I got a question about testing. My code: ``` ...
# general
e
I got a question about testing. My code:
Copy code
const 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:
Copy code
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:
Copy code
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.
s
don't know the answer to your question but here's the reference to those values in secret objects if you want to dig through the source code https://github.com/pulumi/pulumi/blob/432209840aadae81ec9f128c48e92f3ebca1b37f/sdk/go/common/resource/properties.go#L628
e
ah thanks, let me have a look