Hello, newbie here trying to write some unit test ...
# python
l
Hello, newbie here trying to write some unit test similar to this one in python https://www.pulumi.com/blog/testing-your-infrastructure-as-code-with-pulumi/. So i got the test running in pytest and when i tried to assert the output from the s3 bucket that i created, i got a pulumi output object. After some reading it looks like i need to obtain the property using apply but it still doesnt work for me. All i want is to get the id of the s3 bucket that is created :/. Anyone can point me to the right direction?
w
The style of unit tests shown in that article run without ever deploying anything - so output properties like
id
will never be populated - and the callbacks to
apply
will never run. This does generally significantly limit the value of this kind of testing - it can be used to verify inputs - but not outputs or behavior. There was a follow up article that shows a technique that can allow running unit tests during updates - which can allow verifying things like this: https://www.pulumi.com/blog/unit-testing-infrastructure-in-nodejs-and-mocha/ But frankly in my experience by far the highest value testing you can have is tests that spin up real infrastructure and validate it before tearing down. These can still be “unit tests” in the sense that they test one component at a time - but they can test the actual correctness of your infrastructure. There’s a great project - Pitfall - for doing this kind of testing with Pulumi in Python - see https://pulumi-community.slack.com/archives/CB36DSVSA/p1573146387034300.
👍 1
l
Cool thanks for the info
m
@lemon-planet-35664 Let me know if you have any questions