Commit Graph

9 Commits

Author SHA1 Message Date
Will Jones a9621cfb4e
Fix NodeJS SDK mocking of custom resource reads ()
This commit incorporates the tests introduced by @henriiik in  into
the existing test suite for the NodeJS SDK mocks. SDK mocks provide a
means for users wishing to unit test their Pulumi programs to stub out
various bits of Pulumi behaviour. Previously, those wanting to stub out
resource reads (through `.get` static methods) would encounter crashes
or use untested code paths. With the crashes fixed in previous commits,
this commit adds some tests. Moreover, we fix an error whereby mock
reads force a non-custom (component) resource, when in reality it should
be the other way around (since reads don't make sense for component
resources).

Closes 

Co-authored-by: Henrik Sjööh <henriiik@gmail.com>
2024-07-01 16:05:30 +00:00
Daniel Sokolowski 900c127365 Add testing for async TS mocks 2023-06-01 14:13:04 +02:00
Daniel Sokolowski 0b1d787396 Refactor existing mocks tests 2023-06-01 14:08:28 +02:00
Robbie McKinstry e05a3bd81c
Apply autoformat
This commit applies the Rome autoformatter to the Node SDK.
These changes are automatically produced. To reproduce these
changes, run `make format` from inside sdk/nodejs.
2023-04-28 18:27:10 -04:00
Justin Van Patten 1e09626bc7
[sdk/{nodejs,python}] Fix errors when testing remote components with mocks ()
v3.13.0 introduces support for serializing outputs in inputs as special output value objects in the Node.js and Python SDKs when serializing inputs for remote components and method calls. This functionality is currently disabled by default in the engine (setting the `PULUMI_ENABLE_OUTPUT_VALUES` envvar to a truthy value enables it).

However, unit testing remote components with mocks results in errors being raised in v3.13.0, related to the new output value support. This is due to the mock monitor implementation saying it supports all features (which now includes output values), so the SDK serializers are serializing outputs as output values, which the mock monitor can't handle correctly.

This change addresses the issue by updating the mock monitor implementation in the Node.js and Python SDKs to indicate the specific features that are supported, excluding support for output values. New tests with mocks fail before the change and pass after.
2021-09-24 06:08:13 -07:00
Horace Lee a92a005d68
Use ESlint instead of TSlint ()
Migrated TSlint configs to ESlint ones using [tslint-to-eslint-config](https://github.com/typescript-eslint/tslint-to-eslint-config) tool, and refined the configs to better match the current coding style.

Changes:
- [member-delimiter-style](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md#options) that as suggested default for type definition to be  with `semicolon`
- Indentation fixes that is enforced by [eslint-indent](https://eslint.org/docs/rules/indent#options)
- Added dependencies for ESlint with Typescript
- Removed TSlint
2021-08-10 11:31:59 -07:00
Paul Stack e955a6b06a Refactor Mock newResource and call to accept property bag rather than individual args () 2021-04-14 19:32:18 +01:00
James Nugent c1ce3da3e6
Make `custom` available to `Mocks::newResource` ()
This commit adds a new optional parameter to the `newResource` function
of the `Mocks` interface for TypeScript. This can be useful when writing
tests which assert differing behavior between Custom and Component
resources.

Although the new parameter will always be set, the paramteter is marked
as optional in order to maintain backwards compatibility with existing
implementations of `Mocks`.

The tests are updated to verify that `custom` is set appropriately.

Co-authored-by: Luke Hoban <luke@pulumi.com>
2021-03-25 14:22:14 +11:00
Justin Van Patten 918615f072
[sdk/nodejs] Implement getResource in the mock monitor ()
Otherwise, unit tests for programs that reference resources that have been registered with `registerResourceModule` fail with unhandled exceptions.
2020-12-10 09:30:34 -08:00