Skip to content

Commit

Permalink
Merge #11215
Browse files Browse the repository at this point in the history
11215: Test transpiled examples for all languages r=aq17 a=aq17

Cover all languages for examples synced from pulumi/yaml

Co-authored-by: aq17 <aqiu@pulumi.com>
  • Loading branch information
bors[bot] and aq17 committed Nov 1, 2022
2 parents 6754c38 + d3d8451 commit f425ae3
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 1 deletion.
33 changes: 33 additions & 0 deletions pkg/codegen/dotnet/gen_program_test/batchyaml/gen_program_test.go
@@ -0,0 +1,33 @@
package batchyaml

import (
"os"
"testing"

"github.com/stretchr/testify/assert"

"github.com/pulumi/pulumi/pkg/v3/codegen"
codegenDotnet "github.com/pulumi/pulumi/pkg/v3/codegen/dotnet"
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/test"
)

// This specifically tests the synced examples from pulumi/yaml with
// testing/test/testdata/transpiled_examples, as it requires a different SDK path in Check
func TestGenerateProgram(t *testing.T) {
t.Parallel()
err := os.Chdir("../../../dotnet") // chdir into codegen/dotnet
assert.Nil(t, err)

test.TestProgramCodegen(t,
test.ProgramCodegenOptions{
Language: "dotnet",
Extension: "cs",
OutputFile: "Program.cs",
Check: func(t *testing.T, path string, dependencies codegen.StringSet) {
codegenDotnet.Check(t, path, dependencies, "../../../../../../../sdk/dotnet/Pulumi")
},
GenProgram: codegenDotnet.GenerateProgram,
TestCases: test.PulumiPulumiYAMLProgramTests,
},
)
}
@@ -1,4 +1,4 @@
package batch7
package batchyaml

import (
"os"
Expand Down
32 changes: 32 additions & 0 deletions pkg/codegen/nodejs/gen_program_test/batchyaml/gen_program_test.go
@@ -0,0 +1,32 @@
package batchyaml

import (
"os"
"testing"

"github.com/stretchr/testify/assert"

"github.com/pulumi/pulumi/pkg/v3/codegen"
codegenNode "github.com/pulumi/pulumi/pkg/v3/codegen/nodejs"
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/test"
)

// This specifically tests the synced examples from pulumi/yaml with
// testing/test/testdata/transpiled_examples
func TestGenerateProgram(t *testing.T) {
t.Parallel()
err := os.Chdir("../../../nodejs") // chdir into codegen/nodejs
assert.Nil(t, err)

test.TestProgramCodegen(t,
test.ProgramCodegenOptions{
Language: "nodejs",
Extension: "ts",
OutputFile: "index.ts",
Check: func(t *testing.T, path string, dependencies codegen.StringSet) {
codegenNode.Check(t, path, dependencies, true)
},
GenProgram: codegenNode.GenerateProgram,
TestCases: test.PulumiPulumiYAMLProgramTests,
})
}
29 changes: 29 additions & 0 deletions pkg/codegen/python/gen_program_test/batchyaml/gen_program_test.go
@@ -0,0 +1,29 @@
package batchyaml

import (
"os"
"testing"

"github.com/stretchr/testify/assert"

codegenPy "github.com/pulumi/pulumi/pkg/v3/codegen/python"
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/test"
)

// This specifically tests the synced examples from pulumi/yaml with
// testing/test/testdata/transpiled_examples
func TestGenerateProgram(t *testing.T) {
t.Parallel()
err := os.Chdir("../../../python") // chdir into codegen/python
assert.Nil(t, err)

test.TestProgramCodegen(t,
test.ProgramCodegenOptions{
Language: "python",
Extension: "py",
OutputFile: "__main__.py",
Check: codegenPy.Check,
GenProgram: codegenPy.GenerateProgram,
TestCases: test.PulumiPulumiYAMLProgramTests,
})
}
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Random" Version="4.2.0" />
</ItemGroup>

</Project>
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.AzureNative" Version="1.29.0" />
</ItemGroup>

</Project>
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Aws" Version="4.26.0" />
</ItemGroup>

</Project>
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Random" Version="4.2.0" />
</ItemGroup>

</Project>

0 comments on commit f425ae3

Please sign in to comment.