mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
ebcf7455eb
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf". Signed-off-by: Jakub Martin <kubam@spacelift.io> * Gofmt. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Regenerate protobuf. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix comments. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo issue and pull request link changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo comment changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix comment. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo some link changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * make generate && make protobuf Signed-off-by: Jakub Martin <kubam@spacelift.io> --------- Signed-off-by: Jakub Martin <kubam@spacelift.io>
44 lines
983 B
Go
44 lines
983 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package command
|
|
|
|
import (
|
|
"path/filepath"
|
|
"regexp"
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/placeholderplaceholderplaceholder/opentf/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) {
|
|
testCwd(t)
|
|
|
|
s, err := (&StateMeta{}).State()
|
|
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)
|
|
}
|
|
}
|