Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add outputs yielding sp test stack func #101

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

- [sdk] Updated to the latest pulumi protobuf specification.
[#135](https://github.com/pulumi/pulumi-dotnet/pull/135)

- [sdk] Expand service provider test stack to include outputs.
[#101](https://github.com/pulumi/pulumi-dotnet/pull/101)

### Bug Fixes
- [sdk] Fix JSON serialisation of Input<T> types.
Expand Down
25 changes: 25 additions & 0 deletions sdk/Pulumi/Deployment/Deployment_Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,31 @@ public static Task<ImmutableArray<Resource>> TestWithServiceProviderAsync<TStack
where TStack : Stack
=> TestAsync(mocks, runner => runner.RunAsync<TStack>(serviceProvider), options);

/// <summary>
/// Entry point to test a Pulumi application. Deployment will
/// instantiate a new stack instance based on the type passed as TStack
/// type parameter using the given service provider. This method creates
/// no real resources.
/// Note: Currently, unit tests that call
/// <see cref="TestOutputsWithServiceProviderAsync{TStack}(IMocks, IServiceProvider, TestOptions)"/>
/// must run serially; parallel execution is not supported.
/// </summary>
/// <param name="testMocks">Hooks to mock the engine calls.</param>
/// <param name="serviceProvider"></param>
/// <param name="options">Optional settings for the test run.</param>
/// <typeparam name="TStack">The type of the stack to test.</typeparam>
/// <returns>Test result containing created resources, stack outputs and errors, if any.</returns>
public static async Task<(ImmutableArray<Resource> Resources, IDictionary<string, object?> Outputs)> TestOutputsWithServiceProviderAsync<TStack>(IMocks testMocks, IServiceProvider serviceProvider, TestOptions? options = null)
where TStack : Stack
{
var createdResources = await TestAsync(
mocks: testMocks,
runAsync: runner => runner.RunAsync<TStack>(serviceProvider),
options);

return TestResults(createdResources);
}

/// <summary>
/// Entry point to test a Pulumi application. Deployment will
/// instantiate a new stack instance based on the type passed as TStack
Expand Down