pulumi/pkg/codegen/nodejs/gen_test.go

41 lines
937 B
Go
Raw Normal View History

package nodejs
import (
"path/filepath"
"testing"
"github.com/pulumi/pulumi/pkg/v2/codegen/internal/test"
"github.com/stretchr/testify/assert"
)
func TestGeneratePackage(t *testing.T) {
tests := []struct {
2020-09-30 01:00:03 +02:00
name string
schemaDir string
expectedFiles []string
}{
{
"Simple schema with local resource properties",
2020-09-30 01:00:03 +02:00
"simple-resource-schema",
[]string{
"resource.ts",
"otherResource.ts",
"argFunction.ts",
},
},
}
2020-09-30 01:00:03 +02:00
testDir := filepath.Join("..", "internal", "test", "testdata")
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
files, err := test.GeneratePackageFilesFromSchema(
filepath.Join(testDir, tt.schemaDir, "schema.json"), GeneratePackage)
assert.NoError(t, err)
expectedFiles, err := test.LoadFiles(filepath.Join(testDir, tt.schemaDir), tt.expectedFiles)
assert.NoError(t, err)
test.ValidateFileEquality(t, files, expectedFiles)
})
}
}