Skip to content

Commit

Permalink
fix internal/states unit tests Windows (opentofu#1714)
Browse files Browse the repository at this point in the history
Signed-off-by: eduzgun <[email protected]>
  • Loading branch information
eduzgun authored Jun 10, 2024
1 parent b084b3e commit b072580
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/states/statemgr/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ func TestFilesystem_backup(t *testing.T) {
// not the contents of the input file (which is left unchanged).
func TestFilesystem_backupAndReadPath(t *testing.T) {
defer testOverrideVersion(t, "1.2.3")()
info := NewLockInfo()
info.Operation = "test"

workDir := t.TempDir()

markerOutput := addrs.OutputValue{Name: "foo"}.Absolute(addrs.RootModuleInstance)

outState := states.BuildState(func(ss *states.SyncState) {
Expand Down Expand Up @@ -255,6 +256,15 @@ func TestFilesystem_backupAndReadPath(t *testing.T) {
t.Fatalf("failed to write new state: %s", err)
}

lockID, err := ls.Lock(info)
if err != nil {
t.Fatal(err)
}

if err := ls.Unlock(lockID); err != nil {
t.Fatal(err)
}

// The backup functionality should've saved a copy of the original contents
// of the _output_ file, even though the first snapshot was read from
// the _input_ file.
Expand All @@ -263,6 +273,7 @@ func TestFilesystem_backupAndReadPath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer bfh.Close()
bf, err := statefile.Read(bfh, encryption.StateEncryptionDisabled())
if err != nil {
t.Fatal(err)
Expand All @@ -277,6 +288,7 @@ func TestFilesystem_backupAndReadPath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer ofh.Close()
of, err := statefile.Read(ofh, encryption.StateEncryptionDisabled())
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit b072580

Please sign in to comment.