mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
4bdaffb586
Most of the functionality in this package has been obsoleted by equivalent symbols in states/statemgr. We're keeping this package around for the moment mainly just to house the type aliases in state.go. The tests in here no longer work because they are written against the old APIs. We will eventually remove the components these are testing too, but we're keeping them around for the moment so that we don't break the build for some leftover callers that are still depending on these.
53 lines
894 B
Go
53 lines
894 B
Go
package state
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"io/ioutil"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/logging"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
flag.Parse()
|
|
if testing.Verbose() {
|
|
// if we're verbose, use the logging requested by TF_LOG
|
|
logging.SetOutput()
|
|
} else {
|
|
// otherwise silence all logs
|
|
log.SetOutput(ioutil.Discard)
|
|
}
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestNewLockInfo(t *testing.T) {
|
|
info1 := NewLockInfo()
|
|
info2 := NewLockInfo()
|
|
|
|
if info1.ID == "" {
|
|
t.Fatal("LockInfo missing ID")
|
|
}
|
|
|
|
if info1.Version == "" {
|
|
t.Fatal("LockInfo missing version")
|
|
}
|
|
|
|
if info1.Created.IsZero() {
|
|
t.Fatal("LockInfo missing Created")
|
|
}
|
|
|
|
if info1.ID == info2.ID {
|
|
t.Fatal("multiple LockInfo with identical IDs")
|
|
}
|
|
|
|
// test the JSON output is valid
|
|
newInfo := &LockInfo{}
|
|
err := json.Unmarshal(info1.Marshal(), newInfo)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|