Add test for nil *os.File in ReadState

This commit is contained in:
James Bardin 2017-02-09 16:06:07 -05:00
parent 0c1b138719
commit 92cea2478d

View File

@ -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"`