-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
gen_program_test.go
38 lines (33 loc) 路 1.2 KB
/
gen_program_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package batchyaml
import (
"os"
"testing"
"github.com/hashicorp/hcl/v2"
"github.com/stretchr/testify/assert"
"github.com/pulumi/pulumi/pkg/v3/codegen"
codegenGo "github.com/pulumi/pulumi/pkg/v3/codegen/go"
"github.com/pulumi/pulumi/pkg/v3/codegen/pcl"
"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("../../../go") // chdir into codegen/go
assert.Nil(t, err)
test.TestProgramCodegen(t,
test.ProgramCodegenOptions{
Language: "go",
Extension: "go",
OutputFile: "main.go",
Check: func(t *testing.T, path string, dependencies codegen.StringSet) {
codegenGo.Check(t, path, dependencies, "../../../../../../../../sdk")
},
GenProgram: func(program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error) {
// Prevent tests from interfering with each other
return codegenGo.GenerateProgramWithOptions(program,
codegenGo.GenerateProgramOptions{ExternalCache: codegenGo.NewCache()})
},
TestCases: test.PulumiPulumiYAMLProgramTests,
})
}