Provide a default ConsulConfig for client/config.DefaultConfig()

Change the unit test to only test if the consul link exists, not the
value of the link.  The old test was hostname specific and therefore
would always be different based on the environment running the tests.
This commit is contained in:
Sean Chittenden 2016-05-31 13:28:43 -07:00
parent cb80e93a6b
commit 6fdf9135cb
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
2 changed files with 10 additions and 10 deletions

View File

@ -135,6 +135,12 @@ func (c *Config) Copy() *Config {
// DefaultConfig returns the default configuration
func DefaultConfig() *Config {
return &Config{
ConsulConfig: &config.ConsulConfig{
ServerServiceName: "nomad",
ClientServiceName: "nomad-client",
AutoRegister: true,
Timeout: 500 * time.Millisecond,
},
LogOutput: os.Stderr,
Region: "global",
StatsDataPoints: 60,

View File

@ -22,14 +22,9 @@ func TestConsulFingerprint(t *testing.T) {
}))
defer ts.Close()
consulConfig := &config.Config{
Options: map[string]string{
// Split off "http://"
"consul.address": ts.URL[7:],
},
}
config := config.DefaultConfig()
ok, err := fp.Fingerprint(consulConfig, node)
ok, err := fp.Fingerprint(config, node)
if err != nil {
t.Fatalf("Failed to fingerprint: %s", err)
}
@ -43,9 +38,8 @@ func TestConsulFingerprint(t *testing.T) {
assertNodeAttributeContains(t, node, "unique.consul.name")
assertNodeAttributeContains(t, node, "consul.datacenter")
expectedLink := "vagrant.consul2"
if node.Links["consul"] != expectedLink {
t.Errorf("Expected consul link: %s\nFound links: %#v", expectedLink, node.Links)
if _, ok := node.Links["consul"]; !ok {
t.Errorf("Expected a link to consul, none found")
}
}