command: Fix TestInit_checkRequiredVersion
In prior refactoring we lost the required core version check from "terraform init", which we restore here. Additionally, this test used to have an incorrect name that suggested it was testing something in the "getProvider" codepath, but version checking happens regardless of what other options are selected.
This commit is contained in:
parent
9ba399bca8
commit
544c2932ce
|
@ -257,6 +257,24 @@ func (c *InitCommand) Run(args []string) int {
|
|||
}
|
||||
}
|
||||
|
||||
// With modules now installed, we should be able to load the whole
|
||||
// configuration and check the core version constraints.
|
||||
config, confDiags := c.loadConfig(path)
|
||||
diags = diags.Append(confDiags)
|
||||
if confDiags.HasErrors() {
|
||||
// Since this may be the user's first ever interaction with Terraform,
|
||||
// we'll provide some additional context in this case.
|
||||
c.Ui.Error(strings.TrimSpace(errInitConfigError))
|
||||
c.showDiagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
confDiags = terraform.CheckCoreVersionRequirements(config)
|
||||
diags = diags.Append(confDiags)
|
||||
if confDiags.HasErrors() {
|
||||
c.showDiagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
if back == nil {
|
||||
// If we didn't initialize a backend then we'll try to at least
|
||||
// instantiate one. This might fail if it wasn't already initalized
|
||||
|
|
|
@ -959,7 +959,7 @@ func TestInit_getProviderHaveLegacyVersion(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestInit_getProviderCheckRequiredVersion(t *testing.T) {
|
||||
func TestInit_checkRequiredVersion(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-check-required-version"), td)
|
||||
|
|
Loading…
Reference in New Issue