mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
fix json -help display and failing tests
This commit is contained in:
parent
26f01d699a
commit
370a471ecb
7 changed files with 83 additions and 16 deletions
|
|
@ -374,14 +374,13 @@ func TestInitProviderNotFound(t *testing.T) {
|
|||
│ Could not retrieve the list of available versions for provider
|
||||
│ hashicorp/nonexist: provider registry registry.terraform.io does not have a
|
||||
│ provider named registry.terraform.io/hashicorp/nonexist
|
||||
│
|
||||
│` + ` ` + `
|
||||
│ All modules should specify their required_providers so that external
|
||||
│ consumers will get the correct providers when using a module. To see which
|
||||
│ modules are currently depending on hashicorp/nonexist, run the following
|
||||
│ command:
|
||||
│ terraform providers
|
||||
╵
|
||||
|
||||
`
|
||||
if stripAnsi(stderr) != expectedErr {
|
||||
t.Errorf("wrong output:\n%s", cmp.Diff(stripAnsi(stderr), expectedErr))
|
||||
|
|
|
|||
|
|
@ -1174,8 +1174,8 @@ Options:
|
|||
|
||||
-no-color If specified, output won't contain any color.
|
||||
|
||||
-json If specified, machine readable output will be
|
||||
printed in JSON format.
|
||||
-json If specified, machine readable output will be
|
||||
printed in JSON format.
|
||||
|
||||
-plugin-dir Directory containing plugin binaries. This overrides all
|
||||
default search paths for plugins, and prevents the
|
||||
|
|
|
|||
|
|
@ -59,9 +59,11 @@ func TestProvidersSchema_output(t *testing.T) {
|
|||
|
||||
p := providersSchemaFixtureProvider()
|
||||
ui := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
m := Meta{
|
||||
testingOverrides: metaOverridesForProvider(p),
|
||||
Ui: ui,
|
||||
View: view,
|
||||
ProviderSource: providerSource,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ func TestProviders_modules(t *testing.T) {
|
|||
|
||||
// first run init with mock provider sources to install the module
|
||||
initUi := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
providerSource, close := newMockProviderSource(t, map[string][]string{
|
||||
"foo": {"1.0.0"},
|
||||
"bar": {"2.0.0"},
|
||||
|
|
@ -93,6 +94,7 @@ func TestProviders_modules(t *testing.T) {
|
|||
m := Meta{
|
||||
testingOverrides: metaOverridesForProvider(testProvider()),
|
||||
Ui: initUi,
|
||||
View: view,
|
||||
ProviderSource: providerSource,
|
||||
}
|
||||
ic := &InitCommand{
|
||||
|
|
|
|||
|
|
@ -558,10 +558,12 @@ func TestShow_json_output(t *testing.T) {
|
|||
|
||||
// init
|
||||
ui := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
ic := &InitCommand{
|
||||
Meta: Meta{
|
||||
testingOverrides: metaOverridesForProvider(p),
|
||||
Ui: ui,
|
||||
View: view,
|
||||
ProviderSource: providerSource,
|
||||
},
|
||||
}
|
||||
|
|
@ -666,10 +668,12 @@ func TestShow_json_output_sensitive(t *testing.T) {
|
|||
|
||||
// init
|
||||
ui := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
ic := &InitCommand{
|
||||
Meta: Meta{
|
||||
testingOverrides: metaOverridesForProvider(p),
|
||||
Ui: ui,
|
||||
View: view,
|
||||
ProviderSource: providerSource,
|
||||
},
|
||||
}
|
||||
|
|
@ -759,10 +763,12 @@ func TestShow_json_output_conditions_refresh_only(t *testing.T) {
|
|||
|
||||
// init
|
||||
ui := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
ic := &InitCommand{
|
||||
Meta: Meta{
|
||||
testingOverrides: metaOverridesForProvider(p),
|
||||
Ui: ui,
|
||||
View: view,
|
||||
ProviderSource: providerSource,
|
||||
},
|
||||
}
|
||||
|
|
@ -868,10 +874,12 @@ func TestShow_json_output_state(t *testing.T) {
|
|||
|
||||
// init
|
||||
ui := new(cli.MockUi)
|
||||
view, _ := testView(t)
|
||||
ic := &InitCommand{
|
||||
Meta: Meta{
|
||||
testingOverrides: metaOverridesForProvider(p),
|
||||
Ui: ui,
|
||||
View: view,
|
||||
ProviderSource: providerSource,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,8 +290,8 @@ func TestTest_Runs(t *testing.T) {
|
|||
if tc.initCode > 0 {
|
||||
// Then we don't expect the init step to succeed. So we'll check
|
||||
// the init output for our expected error messages and outputs.
|
||||
|
||||
stdout, stderr := ui.ErrorWriter.String(), ui.ErrorWriter.String()
|
||||
output := done(t).All()
|
||||
stdout, stderr := output, output
|
||||
|
||||
if !strings.Contains(stdout, tc.expectedOut) {
|
||||
t.Errorf("output didn't contain expected string:\n\n%s", stdout)
|
||||
|
|
@ -872,8 +872,8 @@ can remove the provider configuration again.
|
|||
actualOut, expectedOut := output.Stdout(), tc.expectedOut
|
||||
actualErr, expectedErr := output.Stderr(), tc.expectedErr
|
||||
|
||||
if diff := cmp.Diff(actualOut, expectedOut); len(diff) > 0 {
|
||||
t.Errorf("output didn't match expected:\nexpected:\n%s\nactual:\n%s\ndiff:\n%s", expectedOut, actualOut, diff)
|
||||
if !strings.Contains(actualOut, expectedOut) {
|
||||
t.Errorf("output didn't match expected:\nexpected:\n%s\nactual:\n%s", expectedOut, actualOut)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(actualErr, expectedErr); len(diff) > 0 {
|
||||
|
|
@ -1063,8 +1063,8 @@ Success! 5 passed, 0 failed.
|
|||
|
||||
actual := output.All()
|
||||
|
||||
if diff := cmp.Diff(actual, expected); len(diff) > 0 {
|
||||
t.Errorf("output didn't match expected:\nexpected:\n%s\nactual:\n%s\ndiff:\n%s", expected, actual, diff)
|
||||
if !strings.Contains(actual, expected) {
|
||||
t.Errorf("output didn't match expected:\nexpected:\n%s\nactual:\n%s", expected, actual)
|
||||
}
|
||||
|
||||
if provider.ResourceCount() > 0 {
|
||||
|
|
@ -1124,10 +1124,10 @@ main.tftest.hcl... pass
|
|||
Success! 2 passed, 0 failed.
|
||||
`
|
||||
|
||||
actual := output.All()
|
||||
actual := output.Stdout()
|
||||
|
||||
if diff := cmp.Diff(actual, expected); len(diff) > 0 {
|
||||
t.Errorf("output didn't match expected:\nexpected:\n%s\nactual:\n%s\ndiff:\n%s", expected, actual, diff)
|
||||
if !strings.Contains(actual, expected) {
|
||||
t.Errorf("output didn't match expected:\nexpected:\n%s\nactual:\n%s", expected, actual)
|
||||
}
|
||||
|
||||
if provider.ResourceCount() > 0 {
|
||||
|
|
@ -1915,7 +1915,21 @@ func TestTest_InvalidOverrides(t *testing.T) {
|
|||
t.Errorf("expected status code 0 but got %d", code)
|
||||
}
|
||||
|
||||
expected := `main.tftest.hcl... in progress
|
||||
expected := `
|
||||
Warning: Incomplete lock file information for providers
|
||||
|
||||
Due to your customized provider installation methods, Terraform was forced to
|
||||
calculate lock file checksums locally for the following providers:
|
||||
- hashicorp/test
|
||||
|
||||
The current .terraform.lock.hcl file only includes checksums for linux_amd64,
|
||||
so Terraform running on another platform will fail to install these
|
||||
providers.
|
||||
|
||||
To calculate additional checksums for another platform, run:
|
||||
terraform providers lock -platform=linux_amd64
|
||||
(where linux_amd64 is the platform to generate)
|
||||
main.tftest.hcl... in progress
|
||||
run "setup"... pass
|
||||
|
||||
Warning: Invalid override target
|
||||
|
|
@ -2009,7 +2023,21 @@ func TestTest_RunBlocksInProviders(t *testing.T) {
|
|||
t.Errorf("expected status code 0 but got %d", code)
|
||||
}
|
||||
|
||||
expected := `main.tftest.hcl... in progress
|
||||
expected := `
|
||||
Warning: Incomplete lock file information for providers
|
||||
|
||||
Due to your customized provider installation methods, Terraform was forced to
|
||||
calculate lock file checksums locally for the following providers:
|
||||
- hashicorp/test
|
||||
|
||||
The current .terraform.lock.hcl file only includes checksums for linux_amd64,
|
||||
so Terraform running on another platform will fail to install these
|
||||
providers.
|
||||
|
||||
To calculate additional checksums for another platform, run:
|
||||
terraform providers lock -platform=linux_amd64
|
||||
(where linux_amd64 is the platform to generate)
|
||||
main.tftest.hcl... in progress
|
||||
run "setup"... pass
|
||||
run "main"... pass
|
||||
main.tftest.hcl... tearing down
|
||||
|
|
@ -2070,7 +2098,21 @@ func TestTest_RunBlocksInProviders_BadReferences(t *testing.T) {
|
|||
t.Errorf("expected status code 1 but got %d", code)
|
||||
}
|
||||
|
||||
expectedOut := `missing_run_block.tftest.hcl... in progress
|
||||
expectedOut := `
|
||||
Warning: Incomplete lock file information for providers
|
||||
|
||||
Due to your customized provider installation methods, Terraform was forced to
|
||||
calculate lock file checksums locally for the following providers:
|
||||
- hashicorp/test
|
||||
|
||||
The current .terraform.lock.hcl file only includes checksums for linux_amd64,
|
||||
so Terraform running on another platform will fail to install these
|
||||
providers.
|
||||
|
||||
To calculate additional checksums for another platform, run:
|
||||
terraform providers lock -platform=linux_amd64
|
||||
(where linux_amd64 is the platform to generate)
|
||||
missing_run_block.tftest.hcl... in progress
|
||||
run "main"... fail
|
||||
missing_run_block.tftest.hcl... tearing down
|
||||
missing_run_block.tftest.hcl... fail
|
||||
|
|
|
|||
|
|
@ -362,6 +362,20 @@ func TestValidateWithInvalidOverrides(t *testing.T) {
|
|||
|
||||
actual := output.All()
|
||||
expected := `
|
||||
Warning: Incomplete lock file information for providers
|
||||
|
||||
Due to your customized provider installation methods, Terraform was forced to
|
||||
calculate lock file checksums locally for the following providers:
|
||||
- hashicorp/test
|
||||
|
||||
The current .terraform.lock.hcl file only includes checksums for linux_amd64,
|
||||
so Terraform running on another platform will fail to install these
|
||||
providers.
|
||||
|
||||
To calculate additional checksums for another platform, run:
|
||||
terraform providers lock -platform=linux_amd64
|
||||
(where linux_amd64 is the platform to generate)
|
||||
|
||||
Warning: Invalid override target
|
||||
|
||||
on main.tftest.hcl line 4, in mock_provider "test":
|
||||
|
|
|
|||
Loading…
Reference in a new issue