mirror of
https://github.com/opentofu/opentofu.git
synced 2026-06-10 00:50:50 -04:00
Some checks are pending
build / Build for freebsd_386 (push) Waiting to run
build / Build for linux_386 (push) Waiting to run
build / Build for openbsd_386 (push) Waiting to run
build / Build for windows_386 (push) Waiting to run
build / Build for freebsd_amd64 (push) Waiting to run
build / Build for linux_amd64 (push) Waiting to run
build / Build for openbsd_amd64 (push) Waiting to run
build / Build for solaris_amd64 (push) Waiting to run
build / Build for windows_amd64 (push) Waiting to run
build / Build for freebsd_arm (push) Waiting to run
build / Build for linux_arm (push) Waiting to run
build / Build for linux_arm64 (push) Waiting to run
build / Build for darwin_amd64 (push) Waiting to run
build / Build for darwin_arm64 (push) Waiting to run
build / End-to-end Tests for linux_386 (push) Waiting to run
build / End-to-end Tests for windows_386 (push) Waiting to run
build / End-to-end Tests for darwin_amd64 (push) Waiting to run
build / End-to-end Tests for linux_amd64 (push) Waiting to run
build / End-to-end Tests for windows_amd64 (push) Waiting to run
Quick Checks / List files changed for pull request (push) Waiting to run
Quick Checks / Unit tests for linux_386 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for windows_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm (push) Blocked by required conditions
Quick Checks / Unit tests for darwin_arm64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm64 (push) Blocked by required conditions
Quick Checks / Race Tests (push) Blocked by required conditions
Quick Checks / End-to-end Tests (push) Blocked by required conditions
Quick Checks / Code Consistency Checks (push) Blocked by required conditions
Quick Checks / License Checks (push) Waiting to run
Website checks / List files changed for pull request (push) Waiting to run
Website checks / Build (push) Blocked by required conditions
Website checks / Test Installation Instructions (push) Blocked by required conditions
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package command
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestBackendMigrate_promptMultiStatePattern(t *testing.T) {
|
|
// Setup the meta
|
|
|
|
cases := map[string]struct {
|
|
renamePrompt string
|
|
patternPrompt string
|
|
expectedErr string
|
|
}{
|
|
"valid pattern": {
|
|
renamePrompt: "1",
|
|
patternPrompt: "hello-*",
|
|
expectedErr: "",
|
|
},
|
|
"invalid pattern, only one asterisk allowed": {
|
|
renamePrompt: "1",
|
|
patternPrompt: "hello-*-world-*",
|
|
expectedErr: "The pattern '*' cannot be used more than once.",
|
|
},
|
|
"invalid pattern, missing asterisk": {
|
|
renamePrompt: "1",
|
|
patternPrompt: "hello-world",
|
|
expectedErr: "The pattern must have an '*'",
|
|
},
|
|
"invalid rename": {
|
|
renamePrompt: "3",
|
|
expectedErr: "Please select 1 or 2 as part of this option.",
|
|
},
|
|
"no rename": {
|
|
renamePrompt: "2",
|
|
},
|
|
}
|
|
for name, tc := range cases {
|
|
t.Log("Test: ", name)
|
|
m := testMetaBackend(t)
|
|
input := map[string]string{}
|
|
cleanup := testInputMap(t, input)
|
|
if tc.renamePrompt != "" {
|
|
input["backend-migrate-multistate-to-tfc"] = tc.renamePrompt
|
|
}
|
|
if tc.patternPrompt != "" {
|
|
input["backend-migrate-multistate-to-tfc-pattern"] = tc.patternPrompt
|
|
}
|
|
|
|
sourceType := "cloud"
|
|
_, err := m.promptMultiStateMigrationPattern(sourceType)
|
|
if tc.expectedErr == "" && err != nil {
|
|
t.Fatalf("expected error to be nil, but was %s", err.Error())
|
|
}
|
|
if tc.expectedErr != "" && tc.expectedErr != err.Error() {
|
|
t.Fatalf("expected error to eq %s but got %s", tc.expectedErr, err.Error())
|
|
}
|
|
|
|
cleanup()
|
|
}
|
|
}
|