Anyone have an example of a passing unit test from...
# golang
s
Anyone have an example of a passing unit test from code that leverages a Resource Hook?
👀 1
I have read this, bit it doesn't account for the tests failing simply because of the registered hook. To rule that out, the hook itself is just a print statement at the moment, that just returns
nil
. If I remove the hook entirely, the tests pass no problem. But just having one in there that prints "hello world" causes a panic like this:
Copy code
panic: not implemented

goroutine 88 [running]:
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*mockMonitor).RegisterResourceHook(0x237ccd1c81b0|github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*mockMonitor).RegisterResourceHook(0x237ccd1c81b0>?, {0x39e5828?, 0x237cccf1d8f0?}, 0x0?, {0x285dd40?, 0x237ccca94eb8?, 0x0?})
        /home/rvoxi/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.253.0/go/pulumi/mocks.go:397 +0x25
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*Context).RegisterResourceHook.func1()|github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*Context).RegisterResourceHook.func1()>
        /home/rvoxi/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.253.0/go/pulumi/context.go:3013 +0x105
created by <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*Context).RegisterResourceHook|github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*Context).RegisterResourceHook> in goroutine 86
        /home/rvoxi/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.253.0/go/pulumi/context.go:2995 +0xc9
The docs say that hooks are ignored by the mock engine. That's fine, I'm not testing for what's inside the hook (my program does not crash if "hello world" is not printed), but my program can't pass a unit test unless I completely comment it out, and remove it entirely from the pulumi resource options of the resource its for.
e
Will be fixed in the next release. Some methods were panic'ing instead of just being no-op returns.
🙏 2