Normalize configs for agent tests

This commit is contained in:
Michael Schurter 2016-11-08 16:13:09 -08:00
parent 6d83a192cf
commit 293c596411
1 changed files with 12 additions and 3 deletions

View File

@ -13,6 +13,14 @@ import (
sconfig "github.com/hashicorp/nomad/nomad/structs/config" sconfig "github.com/hashicorp/nomad/nomad/structs/config"
) )
// getTestLogger returns a log func appropriate for passing to
// Config.normalize()
func getTestLogger(t testing.TB) func(string) {
return func(s string) {
t.Log(s)
}
}
func getPort() int { func getPort() int {
addr, err := net.ResolveTCPAddr("tcp", "localhost:0") addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err != nil { if err != nil {
@ -72,6 +80,9 @@ func makeAgent(t testing.TB, cb func(*Config)) (string, *Agent) {
cb(conf) cb(conf)
} }
if ok := conf.normalize(getTestLogger(t), config.DevMode); !ok {
t.Fatalf("error normalizing config")
}
agent, err := NewAgent(conf, os.Stderr) agent, err := NewAgent(conf, os.Stderr)
if err != nil { if err != nil {
os.RemoveAll(dir) os.RemoveAll(dir)
@ -94,9 +105,7 @@ func TestAgent_RPCPing(t *testing.T) {
func TestAgent_ServerConfig(t *testing.T) { func TestAgent_ServerConfig(t *testing.T) {
conf := DefaultConfig() conf := DefaultConfig()
a := &Agent{config: conf} a := &Agent{config: conf}
testlogger := func(s string) { testlogger := getTestLogger(t)
t.Log(s)
}
dev := false dev := false
// Returns error on bad serf addr // Returns error on bad serf addr