command: Fix TestInit_getProvider
After all of the refactoring we were no longer checking the Terraform version field in a state file, causing this test to fail. This restores that check, though with a slightly different error message.
This commit is contained in:
parent
f6d468ffd5
commit
9ba399bca8
|
@ -691,7 +691,7 @@ func TestInit_getProvider(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
errMsg := ui.ErrorWriter.String()
|
errMsg := ui.ErrorWriter.String()
|
||||||
if !strings.Contains(errMsg, "future Terraform version") {
|
if !strings.Contains(errMsg, "which is newer than current") {
|
||||||
t.Fatal("unexpected error:", errMsg)
|
t.Fatal("unexpected error:", errMsg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,6 +62,15 @@ func Read(r io.Reader) (*File, error) {
|
||||||
panic("readState returned nil state with no errors")
|
panic("readState returned nil state with no errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if state.TerraformVersion != nil && state.TerraformVersion.GreaterThan(tfversion.SemVer) {
|
||||||
|
return state, fmt.Errorf(
|
||||||
|
"state snapshot was created by Terraform v%s, which is newer than current v%s; upgrade to Terraform v%s or greater to work with this state",
|
||||||
|
state.TerraformVersion,
|
||||||
|
tfversion.SemVer,
|
||||||
|
state.TerraformVersion,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return state, diags.Err()
|
return state, diags.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue