mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-04-30 16:03:37 -04:00
Add test for nil *os.File in ReadState
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -1577,6 +1578,20 @@ func TestReadStateNewVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadStateEmptyOrNilFile(t *testing.T) {
|
||||
var emptyState bytes.Buffer
|
||||
_, err := ReadState(&emptyState)
|
||||
if err != ErrNoState {
|
||||
t.Fatal("expected ErrNostate, got", err)
|
||||
}
|
||||
|
||||
var nilFile *os.File
|
||||
_, err = ReadState(nilFile)
|
||||
if err != ErrNoState {
|
||||
t.Fatal("expected ErrNostate, got", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadStateTFVersion(t *testing.T) {
|
||||
type tfVersion struct {
|
||||
Version int `json:"version"`
|
||||
|
||||
Reference in New Issue
Block a user