Adds a test to make sure we get the same ID on the second run.

This commit is contained in:
James Phillips 2017-01-18 09:52:34 -08:00
parent 96bff003b7
commit e73d3c2312
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 9 additions and 0 deletions

View File

@ -322,6 +322,15 @@ func TestAgent_NodeID(t *testing.T) {
t.Fatalf("err: %v", err)
}
// Running again should get the same ID (persisted in the file).
c.NodeID = ""
if err := agent.setupNodeID(c); err != nil {
t.Fatalf("err: %v", err)
}
if newID := agent.consulConfig().NodeID; id != newID {
t.Fatalf("bad: %q vs %q", id, newID)
}
// Set an invalid ID via config.
c.NodeID = types.NodeID("nope")
err := agent.setupNodeID(c)