2020-09-25 21:35:27 +02:00
|
|
|
package nodejs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2020-09-30 22:41:52 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/v2/codegen/internal/test"
|
2020-09-25 21:35:27 +02:00
|
|
|
"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
|
2020-09-25 21:35:27 +02:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
"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-25 21:35:27 +02:00
|
|
|
},
|
|
|
|
}
|
2020-09-30 01:00:03 +02:00
|
|
|
testDir := filepath.Join("..", "internal", "test", "testdata")
|
2020-09-25 21:35:27 +02:00
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2020-09-30 22:41:52 +02:00
|
|
|
files, err := test.GeneratePackageFilesFromSchema(
|
|
|
|
filepath.Join(testDir, tt.schemaDir, "schema.json"), GeneratePackage)
|
2020-09-25 21:35:27 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2020-09-30 22:41:52 +02:00
|
|
|
expectedFiles, err := test.LoadFiles(filepath.Join(testDir, tt.schemaDir), tt.expectedFiles)
|
2020-09-25 21:35:27 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2020-09-30 22:41:52 +02:00
|
|
|
test.ValidateFileEquality(t, files, expectedFiles)
|
2020-09-25 21:35:27 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|