04/11/2023, 5:05 PM
I have a component that doesn’t correctly give each resource it creates a name that will be unique if more than one instance of the component is created in a stack. I’d like to write a unit test to confirm that all the names are unique, but avoid making the test enumerate each resource that’s expected to be created. Is it possible to write such an assertion? I’m looking around for some method that returns all resources that were declared, but I can’t find anything like that. Thoughts?
I ended up adding this check to the
, which fails the test when a duplicate
(TypeToken, Name)
tuple is seen.


04/11/2023, 7:50 PM
Property-based testing could do this. There are good libraries supporting property-based testing in several languages. I've never seen it used with Pulumi but there's no reason it couldn't be.