repl: Make full logging optional in tests

Logs will be hidden unless verbose mode is enabled on the test run.
This commit is contained in:
Martin Atkins 2018-10-02 17:02:48 -07:00
parent dd8b3ab722
commit 9bc153e809
1 changed files with 23 additions and 4 deletions

View File

@ -1,16 +1,35 @@
package repl
import (
"flag"
"io/ioutil"
"log"
"os"
"strings"
"testing"
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/configs"
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/providers"
"github.com/hashicorp/terraform/states"
"github.com/hashicorp/terraform/terraform"
)
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 TestSession_basicState(t *testing.T) {
state := states.BuildState(func(s *states.SyncState) {
s.SetResourceInstanceCurrent(