Pulumock 0.1.5
dotnet add package Pulumock --version 0.1.5
NuGet\Install-Package Pulumock -Version 0.1.5
<PackageReference Include="Pulumock" Version="0.1.5" />
<PackageVersion Include="Pulumock" Version="0.1.5" />
<PackageReference Include="Pulumock" />
paket add Pulumock --version 0.1.5
#r "nuget: Pulumock, 0.1.5"
#:package Pulumock@0.1.5
#addin nuget:?package=Pulumock&version=0.1.5
#tool nuget:?package=Pulumock&version=0.1.5
<p align="center"> <a href="https://github.com/Pulumock/Pulumock" title="Pulumock - A tool designed to address testing challenges in Pulumi .NET"> <img src="pulumock-logo.png" width="150" alt="Project logo" /> </a> </p>
Pulumock
Pulumock your stack before it bites back.
Pulumock is a testing tool for Pulumi .NET projects, designed to simplify and enhance unit testing. Built on top of the standard Pulumi .NET testing capabilities, it addresses common challenges reported by developers, based on real-world data from the Pulumissues dataset.
By using a fluent, strongly typed syntax, Pulumock abstracts away complexity and reduces boilerplate, letting you focus on test logic instead of setup. Pulumock also provides richer data for assertions, enabling more scenarios to be covered.
Table of Contents
Getting Started
Installation
Install the Pulumock NuGet package in your testing project:
dotnet add package Pulumock
Usage
Here’s a simple step-by-step example. For more in-depth instructions, see the documentation.
1. Create a FixtureBuilder
Begin by instantiating a FixtureBuilder
in your test method or wherever appropriate in your codebase:
[Fact]
public async Task ExampleTest()
{
var fixtureBuilder = new FixtureBuilder();
}
2. Add Mocks
Add desired mocks:
[Fact]
public async Task ExampleTest()
{
var fixtureBuilder = new FixtureBuilder()
.WithMockResource(new MockResourceBuilder<ResourceGroup>()
.WithOutput(x => x.Location, "swedencentral")
.Build());
}
3. Execute Test
Build the FixtureBuilder
to run the Pulumi program in test mode, resulting in a Fixture
object
that captures the simulated deployment state without performing any real infrastructure changes:
[Fact]
public async Task ExampleTest()
{
var fixtureBuilder = new FixtureBuilder()
.WithMockResource(new MockResourceBuilder<ResourceGroup>()
.WithOutput(x => x.Location, "swedencentral")
.Build());
var fixture = await fixtureBuilder
.BuildAsync(async () => await CoreStack.DefineResourcesAsync()); // Your code that creates resources.
}
4. Extract information & Write Assertions
Use convenient extension methods to extract information from the Fixture
and write your assertions:
[Fact]
public async Task ExampleTest()
{
var fixtureBuilder = new FixtureBuilder()
.WithMockResource(new MockResourceBuilder<ResourceGroup>()
.WithOutput(x => x.Location, "swedencentral")
.Build());
var fixture = await fixtureBuilder
.BuildAsync(async () => await CoreStack.DefineResourcesAsync()); // Your code that creates resources.
var resourceGroup = fixture.Resources.Require<ResourceGroup>();
var location = await resourceGroup.Location.GetValueAsync();
location.ShouldBe("swedencentral");
}
Documentation
- Explore the Wiki for official documentation and straightforward usage guides.
- Check out the Example project for a working demonstration of Pulumock in action across multiple scenarios.
Contributing
See CONTRIBUTING.md for more information.
License
Pulumock is licensed under the MIT license. Feel free to edit and distribute this project as you like.
See LICENSE for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Pulumi (>= 3.77.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.