Skip to content

Commit

Permalink
drop support for dotnet 3
Browse files Browse the repository at this point in the history
  • Loading branch information
rexebin committed Feb 4, 2024
1 parent 8def3cd commit 09a87f9
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 61 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
DOTNET_VERSION: 8.x
DOTNET_VERSION: 6.x

- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}

Expand All @@ -46,13 +46,14 @@ jobs:
path: ${{ env.NuGetDirectory }}/*.nupkg

validate_nuget:
name: Validate Nuget Package
runs-on: ubuntu-latest
needs: [ create_nuget ]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
DOTNET_VERSION: 8.x
DOTNET_VERSION: 6.x

- uses: actions/download-artifact@v4
with:
Expand All @@ -66,6 +67,7 @@ jobs:
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")

run_test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -74,12 +76,13 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
DOTNET_VERSION: 8.x
DOTNET_VERSION: 6.x

- name: Run tests
run: dotnet test --configuration Release

deploy:
name: Deploy Nuget Package
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ validate_nuget, run_test ]
Expand All @@ -92,7 +95,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
DOTNET_VERSION: 8.x
DOTNET_VERSION: 6.x

- name: Publish NuGet package
run: |
Expand Down
8 changes: 4 additions & 4 deletions PulumiTestHelper.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task Should_Add_ResourceMockFunc(string imageUri)
[Fact]
public async Task Should_Add_ResourceMocks()
{
var result = await _baseStackBuilder.AddResourceMocks([
var (resources, _) = await _baseStackBuilder.AddResourceMocks([
new ResourceMock(typeof(Image),
new Dictionary<string, object>
{
Expand All @@ -108,11 +108,11 @@ public async Task Should_Add_ResourceMocks()
{"repositoryUrl", "my-repository-url"}
})
]).BuildStackAsync<AwsStack>();

var image = result.Resources.OfType<Image>().Single(x => x.HasName("my-image"));
var image = resources.OfType<Image>().Single(x => x.HasName("my-image"));
image.ImageUri.GetValue().Should().Be("my-image-uri");

var repository = result.Resources.OfType<Repository>().Single();
var repository = resources.OfType<Repository>().Single();
repository.RepositoryUrl.GetValue().Should().Be("my-repository-url");
}

Expand Down
6 changes: 1 addition & 5 deletions PulumiTestHelper/Models/CallMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@
/// <summary>
/// Represents a mock for a function call.
/// </summary>
public class CallMock(Type callType, Dictionary<string, object> mocks)
{
internal Type CallType { get; } = callType;
internal Dictionary<string, object> Mocks { get; } = mocks;
}
public record CallMock(Type CallType, Dictionary<string, object> Mocks);
7 changes: 1 addition & 6 deletions PulumiTestHelper/Models/CallMockFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ namespace PulumiTestHelper.Models;
/// <summary>
/// Represents a class that provides a way to define and manage call mock functions.
/// </summary>
public class CallMockFunc(Type callType, Func<MockCallArgs, Dictionary<string, object>> mockFunc)
{
internal Type CallType { get; } = callType;

internal Func<MockCallArgs, Dictionary<string, object>> MockFunc { get; } = mockFunc;
}
public record CallMockFunc(Type CallType, Func<MockCallArgs, Dictionary<string, object>> MockFunc);
7 changes: 1 addition & 6 deletions PulumiTestHelper/Models/ResourceInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ namespace PulumiTestHelper.Models;
/// <summary>
/// Represents a resource input.
/// </summary>
public class ResourceInput(string? identifier, ImmutableDictionary<string, object> inputs)
{
internal string? Identifier { get; } = identifier;

internal ImmutableDictionary<string, object> Inputs { get; } = inputs;
}
public record ResourceInput(string? Identifier, ImmutableDictionary<string, object> Inputs);
6 changes: 1 addition & 5 deletions PulumiTestHelper/Models/ResourceMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ namespace PulumiTestHelper.Models;
/// <summary>
/// Represents a mock for a Pulumi resource.
/// </summary>
public class ResourceMock(Type resourceType, Dictionary<string, object> mocks)
{
internal Type ResourceType { get; } = resourceType;
internal Dictionary<string, object> Mocks { get; set; } = mocks;
}
public record ResourceMock(Type ResourceType, Dictionary<string, object> Mocks);
6 changes: 1 addition & 5 deletions PulumiTestHelper/Models/ResourceMockFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ namespace PulumiTestHelper.Models;
/// <summary>
/// Represents a resource mock function used for mocking resources in Pulumi tests.
/// </summary>
public class ResourceMockFunc(Type resourceType, Func<MockResourceArgs, Dictionary<string, object>> mockFunc)
{
internal Type ResourceType { get; } = resourceType;
internal Func<MockResourceArgs, Dictionary<string, object>> MockFunc { get; } = mockFunc;
}
public record ResourceMockFunc(Type ResourceType, Func<MockResourceArgs, Dictionary<string, object>> MockFunc);
2 changes: 1 addition & 1 deletion PulumiTestHelper/Models/StackReferenceMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace PulumiTestHelper.Models;
/// <summary>
/// Represents a mock for a Pulumi stack reference.
/// </summary>
public class StackReferenceMock : ResourceMock
public record StackReferenceMock : ResourceMock
{
/// <inheritdoc />
public StackReferenceMock(string stackReferenceName, Dictionary<string, object> mocks) : base(
Expand Down
16 changes: 3 additions & 13 deletions PulumiTestHelper/Models/StackResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ namespace PulumiTestHelper.Models;
/// <summary>
/// Represents a result from building a stack.
/// </summary>
/// <param name="resources">List of resources from the stack</param>
/// <param name="resourceInputs">List of resource inputs from the stack</param>
public class StackResult(ImmutableArray<Resource> resources, List<ResourceInput> resourceInputs)
{
/// <summary>
/// List of resources from the stack.
/// </summary>
public ImmutableArray<Resource> Resources { get; } = resources;
/// <summary>
/// List of resource inputs from the stack.
/// </summary>
public List<ResourceInput> ResourceInputs { get; } = resourceInputs;
}
/// <param name="Resources">List of resources from the stack</param>
/// <param name="ResourceInputs">List of resource inputs from the stack</param>
public record StackResult(ImmutableArray<Resource> Resources, List<ResourceInput> ResourceInputs);
2 changes: 1 addition & 1 deletion PulumiTestHelper/PulumiTestHelper.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6;netcoreapp3.1</TargetFrameworks>
<TargetFramework>net6</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
13 changes: 2 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,8 @@ public async Task<StackResult> BuildStackAsync<T>(IServiceProvider serviceProvid
```
#### Example:
```c#
var result = await new StackBuilder().BuildStackAsync<MyStack>();

var resources = result.Resources;
var resourceInputs = result.ResourceInputs;
```

```c#
var result = await new StackBuilder().BuildStackAsync<MyStack>(serviceProvider);

var resources = result.Resources;
var resourceInputs = result.ResourceInputs;
var (resources, resourceInputs) = await new StackBuilder().BuildStackAsync<MyStack>();
var (resources, resourceInputs) = await new StackBuilder().BuildStackAsync<MyStack>(serviceProvider);
```

## Add Mocks for all resources
Expand Down

0 comments on commit 09a87f9

Please sign in to comment.