/
githubmirror
/
terraform
Обзор
Документация
Войти
/
githubmirror
/
terraform
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/command/state_test.go
46 строк
1 KB
Radek Simko
make copyrightfix
17 фев 2026, 16:56
17 фев 2026, 16:56
0fe906f
Код
Авторство
О чём код?
// Copyright IBM Corp. 2014, 2026 // SPDX-License-Identifier: BUSL-1.1 package command import ( "path/filepath" "regexp" "sort" "testing" "github.com/hashicorp/terraform/internal/command/arguments" "github.com/hashicorp/terraform/internal/states/statemgr" ) // testStateBackups returns the list of backups in order of creation // (oldest first) in the given directory. func testStateBackups(t *testing.T, dir string) []string { // Find all the backups list, err := filepath.Glob(filepath.Join(dir, "*"+DefaultBackupExtension)) if err != nil { t.Fatalf("err: %s", err) } // Sort them which will put them naturally in the right order sort.Strings(list) return list } func TestStateDefaultBackupExtension(t *testing.T) { tmp := t.TempDir() t.Chdir(tmp) view := arguments.ViewHuman s, err := (&StateMeta{}).State(view) if err != nil { t.Fatal(err) } backupPath := s.(*statemgr.Filesystem).BackupPath() match := regexp.MustCompile(`terraform\.tfstate\.\d+\.backup$`).MatchString if !match(backupPath) { t.Fatal("Bad backup path:", backupPath) } }