From e719ff8ef128b9a74da7be96d0554f43b1565009 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 18 Jan 2017 09:52:34 -0800 Subject: [PATCH] Adds a test to make sure we get the same ID on the second run. --- command/agent/agent_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 2e2b38bdf8..839edbc7d6 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -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)