https://pulumi.com logo
#general
Title
# general
l

limited-rainbow-51650

04/20/2020, 9:04 PM
I have a custom
pulumi.ComponentResource
. In the constructor of this component, I create a
gcp.compute.Network
. When unit testing, in the
setMocks
function, as in the examples, I do a
switch(type)
and I only left the
default
clause in there with a
console.log
statement. When running the tests, I create an instance of my component. I expect the
newResource
callback to be invoked twice but I only see it for my component, not for the inner
gcp.compute.Network
. Are my expectations wrong?
t

tall-librarian-49374

04/20/2020, 9:28 PM
That’s surprising to me too
l

limited-rainbow-51650

04/20/2020, 9:30 PM
Copy code
pulumi.runtime.setMocks({
    newResource: function(type: string, name: string, inputs: any): {id: string, state: any} {
        console.log(`newResource(${type}, ${name}, ${util.inspect(inputs)})`)
        switch (type) {
...
I moved the log statement to the beginning of
newResource
and it is called only once:
newResource(cumundi:network/gcp:Network, production, {})
On the unit testing front, are there still a lot of changes between 1.14.1 and 2.0.0? I’m on the former and I just noticed the latter became available in Homebrew. 😉
@tall-librarian-49374 it didn’t work with 1.14.1, but I just bumped my NPM packages to 2.0.0 and now it is called twice.
t

tall-librarian-49374

04/20/2020, 9:52 PM
That’s also surprising 🙂
I would expect two versions to behave the same way
2 Views