2017-08-17 10:39:33 -05:00
|
|
|
package init
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/backend/remote-state/inmem"
|
2018-03-20 20:43:02 -05:00
|
|
|
"github.com/zclconf/go-cty/cty"
|
2017-08-17 10:39:33 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDeprecateBackend(t *testing.T) {
|
|
|
|
deprecateMessage := "deprecated backend"
|
|
|
|
deprecatedBackend := deprecateBackend(
|
|
|
|
inmem.New(),
|
|
|
|
deprecateMessage,
|
2018-03-20 20:43:02 -05:00
|
|
|
)
|
2017-08-17 10:39:33 -05:00
|
|
|
|
2018-03-20 20:43:02 -05:00
|
|
|
diags := deprecatedBackend.ValidateConfig(cty.EmptyObjectVal)
|
|
|
|
if len(diags) != 1 {
|
|
|
|
t.Errorf("got %d diagnostics; want 1", len(diags))
|
|
|
|
for _, diag := range diags {
|
|
|
|
t.Errorf("- %s", diag)
|
2017-08-17 10:39:33 -05:00
|
|
|
}
|
2018-03-20 20:43:02 -05:00
|
|
|
return
|
2017-08-17 10:39:33 -05:00
|
|
|
}
|
|
|
|
|
2018-03-20 20:43:02 -05:00
|
|
|
desc := diags[0].Description()
|
|
|
|
if desc.Summary != deprecateMessage {
|
|
|
|
t.Fatalf("wrong message %q; want %q", desc.Summary, deprecateMessage)
|
2017-08-17 10:39:33 -05:00
|
|
|
}
|
|
|
|
}
|