Skip to content

Commit

Permalink
extend config merge test to test merging to empty config
Browse files Browse the repository at this point in the history
  • Loading branch information
David Bresson committed Feb 3, 2017
1 parent 52a4c92 commit 1a6c67d
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions command/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ var (
)

func TestConfig_Merge(t *testing.T) {
c0 := &Config{}

c1 := &Config{
Telemetry: &Telemetry{},
Client: &ClientConfig{},
Server: &ServerConfig{},
Ports: &Ports{},
Addresses: &Addresses{},
AdvertiseAddrs: &AdvertiseAddrs{},
Atlas: &AtlasConfig{},
Vault: &config.VaultConfig{},
Consul: &config.ConsulConfig{},
}

c2 := &Config{
Region: "global",
Datacenter: "dc1",
NodeName: "node1",
Expand Down Expand Up @@ -136,7 +150,7 @@ func TestConfig_Merge(t *testing.T) {
},
}

c2 := &Config{
c3 := &Config{
Region: "region2",
Datacenter: "dc2",
NodeName: "node2",
Expand Down Expand Up @@ -271,9 +285,11 @@ func TestConfig_Merge(t *testing.T) {
},
}

result := c1.Merge(c2)
if !reflect.DeepEqual(result, c2) {
t.Fatalf("bad:\n%#v\n%#v", result, c2)
result := c0.Merge(c1)
result = result.Merge(c2)
result = result.Merge(c3)
if !reflect.DeepEqual(result, c3) {
t.Fatalf("bad:\n%#v\n%#v", result, c3)
}
}

Expand Down

0 comments on commit 1a6c67d

Please sign in to comment.