Skip to content

Commit 1a5ac4f

Browse files
Add basic e2e test for Dotnet (#230)
* First stab at e2e dotnet test * Getting to a plugin install error * More tweaks * This works locally with pulumi@master. Awaiting Pulumi release. Don't need to inlude the Bucket Item Group cleanup
1 parent a438f1f commit 1a5ac4f

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

tests/acc_test.go

+77
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,83 @@ func TestE2eTs(t *testing.T) {
555555
}
556556
}
557557

558+
func TestE2eDotnet(t *testing.T) {
559+
560+
type testCase struct {
561+
name string // Must be same as project folder in testdata/programs/python
562+
moduleName string
563+
moduleVersion string
564+
moduleNamespace string
565+
previewExpect map[apitype.OpType]int
566+
upExpect map[string]int
567+
deleteExpect map[string]int
568+
diffNoChangesExpect map[apitype.OpType]int
569+
}
570+
571+
testcases := []testCase{
572+
{
573+
name: "s3bucketmod",
574+
moduleName: "terraform-aws-modules/s3-bucket/aws",
575+
moduleVersion: "4.5.0",
576+
moduleNamespace: "bucket",
577+
previewExpect: map[apitype.OpType]int{
578+
apitype.OpType("create"): 5,
579+
},
580+
upExpect: map[string]int{
581+
"create": 5,
582+
},
583+
deleteExpect: map[string]int{
584+
"delete": 5,
585+
},
586+
diffNoChangesExpect: map[apitype.OpType]int{
587+
apitype.OpType("same"): 5,
588+
},
589+
},
590+
}
591+
592+
for _, tc := range testcases {
593+
tc := tc
594+
localProviderBinPath := ensureCompiledProvider(t)
595+
skipLocalRunsWithoutCreds(t)
596+
t.Run(tc.name, func(t *testing.T) {
597+
testProgram := filepath.Join("testdata", "programs", "dotnet", tc.name)
598+
integrationTest := pulumitest.NewPulumiTest(
599+
t,
600+
testProgram,
601+
opttest.LocalProviderPath("terraform-module", filepath.Dir(localProviderBinPath)),
602+
opttest.SkipInstall(),
603+
)
604+
605+
// Get a prefix for resource names
606+
prefix := generateTestResourcePrefix()
607+
608+
// Set prefix via config
609+
integrationTest.SetConfig(t, "prefix", prefix)
610+
611+
// Generate package
612+
pulumiPackageAdd(
613+
t,
614+
integrationTest,
615+
localProviderBinPath,
616+
tc.moduleName,
617+
tc.moduleVersion,
618+
tc.moduleNamespace)
619+
620+
previewResult := integrationTest.Preview(t)
621+
autogold.Expect(tc.previewExpect).Equal(t, previewResult.ChangeSummary)
622+
623+
upResult := integrationTest.Up(t)
624+
autogold.Expect(&tc.upExpect).Equal(t, upResult.Summary.ResourceChanges)
625+
626+
previewResult = integrationTest.Preview(t)
627+
autogold.Expect(tc.diffNoChangesExpect).Equal(t, previewResult.ChangeSummary)
628+
629+
destroyResult := integrationTest.Destroy(t)
630+
autogold.Expect(&tc.deleteExpect).Equal(t, destroyResult.Summary.ResourceChanges)
631+
})
632+
}
633+
}
634+
558635
func TestE2ePython(t *testing.T) {
559636

560637
type testCase struct {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Collections.Generic;
2+
using Pulumi;
3+
using Pulumi.Bucket;
4+
5+
return await Deployment.RunAsync(() =>
6+
{
7+
// Add your resources here
8+
// e.g. var resource = new Resource("name", new ResourceArgs { });
9+
var config = new Config();
10+
var prefix = config.Get("prefix") ?? Deployment.Instance.StackName;
11+
var myBucketModule = new Pulumi.Bucket.Module("myBucketModule", new ModuleArgs
12+
{
13+
Bucket = $"{prefix}-test-bucket", // Example argument
14+
// Add other arguments here
15+
});
16+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: s3bucketmod
2+
description: A minimal C# Pulumi program
3+
runtime: dotnet
4+
config:
5+
pulumi:tags:
6+
value:
7+
pulumi:template: csharp
8+
plugins:
9+
providers:
10+
- name: terraform-module
11+
path: /Users/guin/go/src/github.com/pulumi/pulumi-terraform-module-provider/bin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<DefaultItemExcludes>$(DefaultItemExcludes);sdks/**/*.cs</DefaultItemExcludes>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Pulumi" Version="3.*" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)