Silence state package logs during tests

Output log output when testing is verbose
This commit is contained in:
James Bardin 2017-01-27 09:23:27 -05:00
parent f20485550a
commit da0c325e5c
1 changed files with 23 additions and 0 deletions

23
state/state_test.go Normal file
View File

@ -0,0 +1,23 @@
package state
import (
"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())
}