Skip to content

Commit f052ba5

Browse files
committed
fix test and remove unused vars
1 parent 5e1d69f commit f052ba5

File tree

4 files changed

+105
-53
lines changed

4 files changed

+105
-53
lines changed

internal/command/providers_schema_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestProvidersSchema_output(t *testing.T) {
5959

6060
p := providersSchemaFixtureProvider()
6161
ui := new(cli.MockUi)
62-
view, _ := testView(t)
62+
view, done := testView(t)
6363
m := Meta{
6464
testingOverrides: metaOverridesForProvider(p),
6565
Ui: ui,
@@ -72,12 +72,9 @@ func TestProvidersSchema_output(t *testing.T) {
7272
Meta: m,
7373
}
7474
if code := ic.Run([]string{}); code != 0 {
75-
t.Fatalf("init failed\n%s", ui.ErrorWriter)
75+
t.Fatalf("init failed\n%s", done(t).Stderr())
7676
}
7777

78-
// flush the init output from the mock ui
79-
ui.OutputWriter.Reset()
80-
8178
// `terraform provider schemas` command
8279
pc := &ProvidersSchemaCommand{Meta: m}
8380
if code := pc.Run([]string{"-json"}); code != 0 {

internal/command/test_test.go

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,21 @@ func TestTest_SensitiveInputValues(t *testing.T) {
17101710
t.Errorf("expected status code 0 but got %d", code)
17111711
}
17121712

1713-
expected := `main.tftest.hcl... in progress
1713+
expected := `Initializing the backend...
1714+
Initializing modules...
1715+
- test.main.setup in setup
1716+
Initializing provider plugins...
1717+
1718+
Terraform has been successfully initialized!
1719+
1720+
You may now begin working with Terraform. Try running "terraform plan" to see
1721+
any changes that are required for your infrastructure. All Terraform commands
1722+
should now work.
1723+
1724+
If you ever set or change modules or backend configuration for Terraform,
1725+
rerun this command to reinitialize your working directory. If you forget, other
1726+
commands will detect it and remind you to do so if necessary.
1727+
main.tftest.hcl... in progress
17141728
run "setup"... pass
17151729
run "test"... pass
17161730
@@ -1915,7 +1929,20 @@ func TestTest_InvalidOverrides(t *testing.T) {
19151929
t.Errorf("expected status code 0 but got %d", code)
19161930
}
19171931

1918-
expected := `
1932+
expected := `Initializing the backend...
1933+
Initializing modules...
1934+
- setup in setup
1935+
- test.main.setup in setup
1936+
Initializing provider plugins...
1937+
- Finding latest version of hashicorp/test...
1938+
- Installing hashicorp/test v1.0.0...
1939+
- Installed hashicorp/test v1.0.0 (verified checksum)
1940+
Terraform has created a lock file .terraform.lock.hcl to record the provider
1941+
selections it made above. Include this file in your version control repository
1942+
so that Terraform can guarantee to make the same selections by default when
1943+
you run "terraform init" in the future.
1944+
1945+
19191946
Warning: Incomplete lock file information for providers
19201947
19211948
Due to your customized provider installation methods, Terraform was forced to
@@ -1929,6 +1956,15 @@ providers.
19291956
To calculate additional checksums for another platform, run:
19301957
terraform providers lock -platform=linux_amd64
19311958
(where linux_amd64 is the platform to generate)
1959+
Terraform has been successfully initialized!
1960+
1961+
You may now begin working with Terraform. Try running "terraform plan" to see
1962+
any changes that are required for your infrastructure. All Terraform commands
1963+
should now work.
1964+
1965+
If you ever set or change modules or backend configuration for Terraform,
1966+
rerun this command to reinitialize your working directory. If you forget, other
1967+
commands will detect it and remind you to do so if necessary.
19321968
main.tftest.hcl... in progress
19331969
run "setup"... pass
19341970
@@ -2023,7 +2059,19 @@ func TestTest_RunBlocksInProviders(t *testing.T) {
20232059
t.Errorf("expected status code 0 but got %d", code)
20242060
}
20252061

2026-
expected := `
2062+
expected := `Initializing the backend...
2063+
Initializing modules...
2064+
- test.main.setup in setup
2065+
Initializing provider plugins...
2066+
- Finding latest version of hashicorp/test...
2067+
- Installing hashicorp/test v1.0.0...
2068+
- Installed hashicorp/test v1.0.0 (verified checksum)
2069+
Terraform has created a lock file .terraform.lock.hcl to record the provider
2070+
selections it made above. Include this file in your version control repository
2071+
so that Terraform can guarantee to make the same selections by default when
2072+
you run "terraform init" in the future.
2073+
2074+
20272075
Warning: Incomplete lock file information for providers
20282076
20292077
Due to your customized provider installation methods, Terraform was forced to
@@ -2037,6 +2085,15 @@ providers.
20372085
To calculate additional checksums for another platform, run:
20382086
terraform providers lock -platform=linux_amd64
20392087
(where linux_amd64 is the platform to generate)
2088+
Terraform has been successfully initialized!
2089+
2090+
You may now begin working with Terraform. Try running "terraform plan" to see
2091+
any changes that are required for your infrastructure. All Terraform commands
2092+
should now work.
2093+
2094+
If you ever set or change modules or backend configuration for Terraform,
2095+
rerun this command to reinitialize your working directory. If you forget, other
2096+
commands will detect it and remind you to do so if necessary.
20402097
main.tftest.hcl... in progress
20412098
run "setup"... pass
20422099
run "main"... pass
@@ -2098,7 +2155,17 @@ func TestTest_RunBlocksInProviders_BadReferences(t *testing.T) {
20982155
t.Errorf("expected status code 1 but got %d", code)
20992156
}
21002157

2101-
expectedOut := `
2158+
expectedOut := `Initializing the backend...
2159+
Initializing provider plugins...
2160+
- Finding latest version of hashicorp/test...
2161+
- Installing hashicorp/test v1.0.0...
2162+
- Installed hashicorp/test v1.0.0 (verified checksum)
2163+
Terraform has created a lock file .terraform.lock.hcl to record the provider
2164+
selections it made above. Include this file in your version control repository
2165+
so that Terraform can guarantee to make the same selections by default when
2166+
you run "terraform init" in the future.
2167+
2168+
21022169
Warning: Incomplete lock file information for providers
21032170
21042171
Due to your customized provider installation methods, Terraform was forced to
@@ -2112,6 +2179,15 @@ providers.
21122179
To calculate additional checksums for another platform, run:
21132180
terraform providers lock -platform=linux_amd64
21142181
(where linux_amd64 is the platform to generate)
2182+
Terraform has been successfully initialized!
2183+
2184+
You may now begin working with Terraform. Try running "terraform plan" to see
2185+
any changes that are required for your infrastructure. All Terraform commands
2186+
should now work.
2187+
2188+
If you ever set or change modules or backend configuration for Terraform,
2189+
rerun this command to reinitialize your working directory. If you forget, other
2190+
commands will detect it and remind you to do so if necessary.
21152191
missing_run_block.tftest.hcl... in progress
21162192
run "main"... fail
21172193
missing_run_block.tftest.hcl... tearing down

internal/command/validate_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,20 @@ func TestValidateWithInvalidOverrides(t *testing.T) {
361361
}
362362

363363
actual := output.All()
364-
expected := `
364+
expected := `Initializing the backend...
365+
Initializing modules...
366+
- setup in setup
367+
- test.main.setup in setup
368+
Initializing provider plugins...
369+
- Finding latest version of hashicorp/test...
370+
- Installing hashicorp/test v1.0.0...
371+
- Installed hashicorp/test v1.0.0 (verified checksum)
372+
Terraform has created a lock file .terraform.lock.hcl to record the provider
373+
selections it made above. Include this file in your version control repository
374+
so that Terraform can guarantee to make the same selections by default when
375+
you run "terraform init" in the future.
376+
377+
365378
Warning: Incomplete lock file information for providers
366379
367380
Due to your customized provider installation methods, Terraform was forced to
@@ -375,6 +388,15 @@ providers.
375388
To calculate additional checksums for another platform, run:
376389
terraform providers lock -platform=linux_amd64
377390
(where linux_amd64 is the platform to generate)
391+
Terraform has been successfully initialized!
392+
393+
You may now begin working with Terraform. Try running "terraform plan" to see
394+
any changes that are required for your infrastructure. All Terraform commands
395+
should now work.
396+
397+
If you ever set or change modules or backend configuration for Terraform,
398+
rerun this command to reinitialize your working directory. If you forget, other
399+
commands will detect it and remind you to do so if necessary.
378400
379401
Warning: Invalid override target
380402

internal/command/views/init.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -315,49 +315,6 @@ If you ever set or change modules or Terraform Settings, run "terraform init"
315315
again to reinitialize your working directory.
316316
`
317317

318-
// providerProtocolTooOld is a message sent to the CLI UI if the provider's
319-
// supported protocol versions are too old for the user's version of terraform,
320-
// but a newer version of the provider is compatible.
321-
const providerProtocolTooOld = `Provider %q v%s is not compatible with Terraform %s.
322-
Provider version %s is the latest compatible version. Select it with the following version constraint:
323-
version = %q
324-
325-
Terraform checked all of the plugin versions matching the given constraint:
326-
%s
327-
328-
Consult the documentation for this provider for more information on compatibility between provider and Terraform versions.
329-
`
330-
331-
// providerProtocolTooNew is a message sent to the CLI UI if the provider's
332-
// supported protocol versions are too new for the user's version of terraform,
333-
// and the user could either upgrade terraform or choose an older version of the
334-
// provider.
335-
const providerProtocolTooNew = `Provider %q v%s is not compatible with Terraform %s.
336-
You need to downgrade to v%s or earlier. Select it with the following constraint:
337-
version = %q
338-
339-
Terraform checked all of the plugin versions matching the given constraint:
340-
%s
341-
342-
Consult the documentation for this provider for more information on compatibility between provider and Terraform versions.
343-
Alternatively, upgrade to the latest version of Terraform for compatibility with newer provider releases.
344-
`
345-
346-
// incompleteLockFileInformationHeader is the summary displayed to users when
347-
// the lock file has only recorded local hashes.
348-
const incompleteLockFileInformationHeader = `Incomplete lock file information for providers`
349-
350-
// incompleteLockFileInformationBody is the body of text displayed to users when
351-
// the lock file has only recorded local hashes.
352-
const incompleteLockFileInformationBody = `Due to your customized provider installation methods, Terraform was forced to calculate lock file checksums locally for the following providers:
353-
- %s
354-
355-
The current .terraform.lock.hcl file only includes checksums for %s, so Terraform running on another platform will fail to install these providers.
356-
357-
To calculate additional checksums for another platform, run:
358-
terraform providers lock -platform=linux_amd64
359-
(where linux_amd64 is the platform to generate)`
360-
361318
const previousLockInfoHuman = `
362319
Terraform has created a lock file [bold].terraform.lock.hcl[reset] to record the provider
363320
selections it made above. Include this file in your version control repository

0 commit comments

Comments
 (0)