mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Fix test crash when using deprecated outputs in the root module (#3249)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
@@ -54,6 +54,7 @@ BUG FIXES:
|
||||
* Ensure that generated mock values for testing correctly follows the provider schema. ([#3069](https://github.com/opentofu/opentofu/pull/3069))
|
||||
* Remote provisioners now reject SSH certificates whose signature key is a certificate key, as required by the current SSH Certificate Format specification draft. ([#3180](https://github.com/opentofu/opentofu/pull/3180))
|
||||
* `tofu import` command now correctly validates when the target address contains non-existent for_each key ([#3106](https://github.com/opentofu/opentofu/pull/3106))
|
||||
* Fix crash in tofu test when using deprecated outputs ([#3249](https://github.com/opentofu/opentofu/pull/3249))
|
||||
|
||||
BREAKING CHANGES:
|
||||
* In the `azurerm` backend, the following backend variables have been changed ([#3034](https://github.com/opentofu/opentofu/pull/3034)):
|
||||
|
||||
@@ -1609,3 +1609,27 @@ func TestTest_MockProviderValidationForEach(t *testing.T) {
|
||||
t.Fatalf("expected status code 0 but got %d: %s", code, output.All())
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/opentofu/opentofu/issues/3246
|
||||
func TestTest_DeprecatedOutputs(t *testing.T) {
|
||||
td := t.TempDir()
|
||||
testCopyDir(t, testFixturePath("test/deprecated_outputs"), td)
|
||||
t.Chdir(td)
|
||||
|
||||
view, done := testView(t)
|
||||
ui := new(cli.MockUi)
|
||||
meta := Meta{
|
||||
Ui: ui,
|
||||
View: view,
|
||||
}
|
||||
|
||||
testCmd := &TestCommand{
|
||||
Meta: meta,
|
||||
}
|
||||
|
||||
code := testCmd.Run(nil)
|
||||
output := done(t)
|
||||
if code != 0 {
|
||||
t.Fatalf("expected status code 0 but got %d: %s", code, output.All())
|
||||
}
|
||||
}
|
||||
|
||||
4
internal/command/testdata/test/deprecated_outputs/main.tf
vendored
Normal file
4
internal/command/testdata/test/deprecated_outputs/main.tf
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
output "example" {
|
||||
value = "example"
|
||||
deprecated = "for reasons"
|
||||
}
|
||||
8
internal/command/testdata/test/deprecated_outputs/main.tftest.hcl
vendored
Normal file
8
internal/command/testdata/test/deprecated_outputs/main.tftest.hcl
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
run "example" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = output.example == "example"
|
||||
error_message = "ruh-roh"
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,12 @@ func Deprecated(v cty.Value, cause DeprecationCause) cty.Value {
|
||||
// DeprecatedOutput marks a given values as deprecated constructing a DeprecationCause
|
||||
// from module output specific data.
|
||||
func DeprecatedOutput(v cty.Value, addr addrs.AbsOutputValue, msg string, isFromRemoteModule bool) cty.Value {
|
||||
if addr.Module.IsRoot() {
|
||||
// Marking a root output as deprecated has no impact.
|
||||
// We hit this case when using the test framework on a module however.
|
||||
// This is requried as the ModuleCallOutput() below will panic on the root module.
|
||||
return v
|
||||
}
|
||||
_, callOutAddr := addr.ModuleCallOutput()
|
||||
return Deprecated(v, DeprecationCause{
|
||||
IsFromRemoteModule: isFromRemoteModule,
|
||||
|
||||
Reference in New Issue
Block a user