pulumi/tests/smoke_test.go

404 lines
13 KiB
Go
Raw Normal View History

package tests
import (
"encoding/json"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
ptesting "github.com/pulumi/pulumi/sdk/v3/go/common/testing"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var Runtimes = []string{"python", "java", "go", "yaml", "nodejs", "dotnet"}
// Mapping from the language runtime names to the common language name used by templates and the like.
var Languages = map[string]string{
"python": "python",
"java": "java",
"go": "go",
"yaml": "yaml",
"nodejs": "typescript",
"dotnet": "csharp",
}
// Quick sanity tests for each downstream language to check that a minimal example can be created and run.
//
//nolint:paralleltest // pulumi new is not parallel safe
func TestLanguageNewSmoke(t *testing.T) {
// make sure we can download needed plugins
t.Setenv("PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION", "false")
for _, runtime := range Runtimes {
t.Run(runtime, func(t *testing.T) {
//nolint:paralleltest
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
// `new` wants to work in an empty directory but our use of local filestate means we have a
// ".pulumi" directory at root.
projectDir := filepath.Join(e.RootPath, "project")
err := os.Mkdir(projectDir, 0o700)
require.NoError(t, err)
e.CWD = projectDir
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "new", "random-"+Languages[runtime], "--yes")
e.RunCommand("pulumi", "up", "--yes")
e.RunCommand("pulumi", "destroy", "--yes")
})
}
}
// Quick sanity tests that YAML convert works.
Use the yaml converter plugin rather than Eject (#14437) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> We add some hooks to ensure we always use the version of pulumi-converter-yaml that matches the version of yaml we've linked the CLI to, this preserves the behaviour we have today that eject code matches the gen code. At some point it will make sense to decouple these and often just default to the the latest converter instead. This unlinks one part of the yaml codebase from the cli. We still need to do codegen and docgen, but this at least means breaking changes can be made to the eject interface without breaking the build because of the circular dependency cycle. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works - Covered by `TestYamlConvertSmoke` <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-08 08:55:49 +00:00
//
//nolint:paralleltest // sets envvars
func TestYamlConvertSmoke(t *testing.T) {
Use the yaml converter plugin rather than Eject (#14437) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> We add some hooks to ensure we always use the version of pulumi-converter-yaml that matches the version of yaml we've linked the CLI to, this preserves the behaviour we have today that eject code matches the gen code. At some point it will make sense to decouple these and often just default to the the latest converter instead. This unlinks one part of the yaml codebase from the cli. We still need to do codegen and docgen, but this at least means breaking changes can be made to the eject interface without breaking the build because of the circular dependency cycle. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works - Covered by `TestYamlConvertSmoke` <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-08 08:55:49 +00:00
// make sure we can download the yaml converter plugin
t.Setenv("PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION", "false")
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/random_yaml")
// Make sure random is installed
e.RunCommand("pulumi", "plugin", "install", "resource", "random", "4.13.0")
e.RunCommand(
"pulumi", "convert", "--strict",
"--language", "pcl", "--from", "yaml", "--out", "out")
actualPcl, err := os.ReadFile(filepath.Join(e.RootPath, "out", "program.pp"))
require.NoError(t, err)
assert.Equal(t, `resource pet "random:index/randomPet:RandomPet" {
__logicalName = "pet"
}
output name {
__logicalName = "name"
value = pet.id
}
`, string(actualPcl))
}
// Quick sanity tests for each downstream language to check that convert works.
func TestLanguageConvertSmoke(t *testing.T) {
t.Parallel()
for _, runtime := range Runtimes {
runtime := runtime
t.Run(runtime, func(t *testing.T) {
t.Parallel()
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/random_pp")
// Make sure random is installed
e.RunCommand("pulumi", "plugin", "install", "resource", "random", "4.13.0")
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand(
"pulumi", "convert", "--strict",
"--language", Languages[runtime], "--from", "pcl", "--out", "out")
e.CWD = filepath.Join(e.RootPath, "out")
e.RunCommand("pulumi", "stack", "init", "test")
Add install command (#13081) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes https://github.com/pulumi/pulumi/issues/10990. This also includes a couple of fixes for python to get the `TestLanguageConvertComponentSmoke` test working for it. Firstly it fixes InstallDependencies to not create a venv if no venv path is set. The language host was trying to install a venv to the same directory as the program itself (that is not nested under "venv" or the like). But then because the runtime option wasn't set the execution wasn't using that created venv anyway. Secondly the imports for components are not relative. We're not in a proper module when running a python program so relative imports to side-by-side component folders don't work. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-10-25 16:03:02 +00:00
e.RunCommand("pulumi", "install")
e.RunCommand("pulumi", "up", "--yes")
e.RunCommand("pulumi", "destroy", "--yes")
2023-05-26 10:32:19 +00:00
})
}
}
// Quick sanity tests for each downstream language to check that non-strict convert works.
func TestLanguageConvertLenientSmoke(t *testing.T) {
t.Parallel()
for _, runtime := range Runtimes {
runtime := runtime
t.Run(runtime, func(t *testing.T) {
t.Parallel()
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/bad_random_pp")
// Make sure random is installed
e.RunCommand("pulumi", "plugin", "install", "resource", "random", "4.13.0")
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand(
"pulumi", "convert", "--generate-only",
"--language", Languages[runtime], "--from", "pcl", "--out", "out")
// We don't want care about running this program because it _will_ be incorrect.
})
}
}
2023-05-26 10:32:19 +00:00
// Quick sanity tests for each downstream language to check that convert with components works.
func TestLanguageConvertComponentSmoke(t *testing.T) {
t.Parallel()
for _, runtime := range Runtimes {
runtime := runtime
t.Run(runtime, func(t *testing.T) {
t.Parallel()
if runtime == "yaml" {
t.Skip("yaml doesn't support components")
}
if runtime == "java" {
Add install command (#13081) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes https://github.com/pulumi/pulumi/issues/10990. This also includes a couple of fixes for python to get the `TestLanguageConvertComponentSmoke` test working for it. Firstly it fixes InstallDependencies to not create a venv if no venv path is set. The language host was trying to install a venv to the same directory as the program itself (that is not nested under "venv" or the like). But then because the runtime option wasn't set the execution wasn't using that created venv anyway. Secondly the imports for components are not relative. We're not in a proper module when running a python program so relative imports to side-by-side component folders don't work. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-10-25 16:03:02 +00:00
t.Skip("java doesn't support components")
2023-05-26 10:32:19 +00:00
}
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/component_pp")
// Make sure random is installed
e.RunCommand("pulumi", "plugin", "install", "resource", "random", "4.13.0")
2023-05-26 10:32:19 +00:00
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "convert", "--language", Languages[runtime], "--from", "pcl", "--out", "out")
e.CWD = filepath.Join(e.RootPath, "out")
e.RunCommand("pulumi", "stack", "init", "test")
Add install command (#13081) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes https://github.com/pulumi/pulumi/issues/10990. This also includes a couple of fixes for python to get the `TestLanguageConvertComponentSmoke` test working for it. Firstly it fixes InstallDependencies to not create a venv if no venv path is set. The language host was trying to install a venv to the same directory as the program itself (that is not nested under "venv" or the like). But then because the runtime option wasn't set the execution wasn't using that created venv anyway. Secondly the imports for components are not relative. We're not in a proper module when running a python program so relative imports to side-by-side component folders don't work. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-10-25 16:03:02 +00:00
// TODO(https://github.com/pulumi/pulumi/issues/14339): This doesn't work for Go yet because the
// source code convert emits is not valid
if runtime != "go" {
e.RunCommand("pulumi", "install")
e.RunCommand("pulumi", "up", "--yes")
e.RunCommand("pulumi", "destroy", "--yes")
}
})
}
}
// Quick sanity tests for each downstream language to check that sdk-gen works.
func TestLanguageGenerateSmoke(t *testing.T) {
t.Parallel()
for _, runtime := range Runtimes {
if runtime == "yaml" {
// yaml doesn't support sdks
continue
}
runtime := runtime
t.Run(runtime, func(t *testing.T) {
t.Parallel()
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/simple_schema")
e.RunCommand("pulumi", "package", "gen-sdk", "--language", runtime, "schema.json")
})
}
}
2023-06-26 12:24:14 +00:00
//nolint:paralleltest // disabled parallel because we change the plugins cache
func TestPackageGetSchema(t *testing.T) {
t.Setenv("PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION", "false")
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
removeRandomFromLocalPlugins := func() {
e.RunCommand("pulumi", "plugin", "rm", "resource", "random", "--all", "--yes")
}
bindSchema := func(schemaJson string) {
var schemaSpec *schema.PackageSpec
err := json.Unmarshal([]byte(schemaJson), &schemaSpec)
require.NoError(t, err, "Unmarshalling schema specs from random should work")
require.NotNil(t, schemaSpec, "Specification should be non-nil")
schema, diags, err := schema.BindSpec(*schemaSpec, nil)
require.NoError(t, err, "Binding the schema spec should work")
require.False(t, diags.HasErrors(), "Binding schema spec should have no errors")
require.NotNil(t, schema)
}
// Make sure the random provider is not installed locally
// So that we can test the `package get-schema` command works if the plugin
// is not installed locally on first run.
out, _ := e.RunCommand("pulumi", "plugin", "ls")
if strings.Contains(out, "random resource") {
removeRandomFromLocalPlugins()
}
// get the schema and bind it
2023-06-26 09:50:06 +00:00
schemaJSON, _ := e.RunCommand("pulumi", "package", "get-schema", "random")
bindSchema(schemaJSON)
// try again using a specific version
removeRandomFromLocalPlugins()
2023-06-26 09:50:06 +00:00
schemaJSON, _ = e.RunCommand("pulumi", "package", "get-schema", "random@4.13.0")
bindSchema(schemaJSON)
// Now that the random provider is installed, run the command again without removing random from plugins
2023-06-26 09:50:06 +00:00
schemaJSON, _ = e.RunCommand("pulumi", "package", "get-schema", "random")
bindSchema(schemaJSON)
// Now try to get the schema from the path to the binary
pulumiHome, err := workspace.GetPulumiHomeDir()
require.NoError(t, err)
binaryPath := filepath.Join(
pulumiHome,
"plugins",
"resource-random-v4.13.0",
"pulumi-resource-random")
if runtime.GOOS == "windows" {
binaryPath += ".exe"
}
2023-06-26 09:50:06 +00:00
schemaJSON, _ = e.RunCommand("pulumi", "package", "get-schema", binaryPath)
bindSchema(schemaJSON)
}
2023-06-26 12:24:14 +00:00
//nolint:paralleltest // disabled parallel because we change the plugins cache
func TestPackageGetMapping(t *testing.T) {
t.Setenv("PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION", "false")
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
removeRandomFromLocalPlugins := func() {
e.RunCommand("pulumi", "plugin", "rm", "resource", "random", "--all", "--yes")
}
// Make sure the random provider is not installed locally
// So that we can test the `package get-mapping` command works if the plugin
// is not installed locally on first run.
out, _ := e.RunCommand("pulumi", "plugin", "ls")
if strings.Contains(out, "random resource") {
removeRandomFromLocalPlugins()
}
result, _ := e.RunCommand("pulumi", "package", "get-mapping", "terraform", "random@4.13.0", "--out", "mapping.json")
require.Contains(t, result, "random@4.13.0 maps to provider random")
contents, err := os.ReadFile(filepath.Join(e.RootPath, "mapping.json"))
require.NoError(t, err, "Reading the generated tf mapping from file should work")
require.NotNil(t, contents, "mapping contents should be non-empty")
}
// Quick sanity tests for each downstream language to check that import works.
//
//nolint:paralleltest // pulumi new is not parallel safe
func TestLanguageImportSmoke(t *testing.T) {
t.Setenv("PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION", "false")
for _, runtime := range Runtimes {
t.Run(runtime, func(t *testing.T) {
//nolint:paralleltest
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
// `new` wants to work in an empty directory but our use of local filestate means we have a
// ".pulumi" directory at root.
projectDir := filepath.Join(e.RootPath, "project")
err := os.Mkdir(projectDir, 0o700)
require.NoError(t, err)
e.CWD = projectDir
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "new", Languages[runtime], "--yes")
e.RunCommand("pulumi", "import", "--yes", "random:index/randomId:RandomId", "identifier", "p-9hUg")
})
}
}
Add an envar to disable automatic provider installation (#14083) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> This is primarily for the providers team to enable during builds so they can have more confidence about reproducibility of builds (especially examples conversion), but I imagine some customers would enable this as well. Fixes #14086 ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-10-03 15:35:23 +00:00
// Test that PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION disables plugin acquisition in convert.
//
//nolint:paralleltest // changes env vars and plugin cache
func TestConvertDisableAutomaticPluginAcquisition(t *testing.T) {
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/aws_tf")
// Delete all cached plugins and disable plugin acquisition.
e.RunCommand("pulumi", "plugin", "rm", "--all", "--yes")
// Disable acquisition.
e.SetEnvVars("PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=true")
// This should fail because of no terraform converter
_, stderr := e.RunCommandExpectError(
"pulumi", "convert",
"--language", "pcl", "--from", "terraform", "--out", "out")
assert.Contains(t, stderr, "no converter plugin 'pulumi-converter-terraform' found")
// Install a _specific_ version of the terraform converter (so this test doesn't change due to a new release)
e.RunCommand("pulumi", "plugin", "install", "converter", "terraform", "v1.0.8")
// This should now convert, but won't use our full aws tokens
e.RunCommand(
"pulumi", "convert",
"--language", "pcl", "--from", "terraform", "--out", "out")
output, err := os.ReadFile(filepath.Join(e.RootPath, "out", "main.pp"))
require.NoError(t, err)
// If we had an AWS plugin and mapping this would be "aws:ec2/instance:Instance"
assert.Contains(t, string(output), "\"aws:index:instance\"")
}
Add --import-file to pulumi preview (#14548) <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes https://github.com/pulumi/pulumi/issues/12768. This will generate an import file for every resource the preview wants to Create. ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-05 08:32:40 +00:00
// Small integration test for preview --import-file
func TestPreviewImportFile(t *testing.T) {
t.Parallel()
e := ptesting.NewEnvironment(t)
defer deleteIfNotFailed(e)
e.ImportDirectory("testdata/import_node")
// Make sure random is installed
e.RunCommand("pulumi", "plugin", "install", "resource", "random", "4.12.0")
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "stack", "init", "test")
e.RunCommand("pulumi", "install")
e.RunCommand("pulumi", "preview", "--import-file", "import.json")
expectedResources := []interface{}{
map[string]interface{}{
"id": "<PLACEHOLDER>",
"name": "username",
"type": "random:index/randomPet:RandomPet",
"version": "4.12.0",
},
map[string]interface{}{
"name": "component",
"type": "pkg:index:MyComponent",
"component": true,
},
map[string]interface{}{
"id": "<PLACEHOLDER>",
"name": "username",
"type": "random:index/randomPet:RandomPet",
"version": "4.12.0",
"parent": "component",
},
}
importBytes, err := os.ReadFile(filepath.Join(e.CWD, "import.json"))
require.NoError(t, err)
var actual map[string]interface{}
err = json.Unmarshal(importBytes, &actual)
require.NoError(t, err)
assert.ElementsMatch(t, expectedResources, actual["resources"])
_, has := actual["nameTable"]
assert.False(t, has, "nameTable should not be present in import file")
}