From fe245396d12c0ff81d9ab686525ea21447cc5359 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Fri, 11 Sep 2015 11:10:20 -0700 Subject: [PATCH] command: tests --- command/agent_info_test.go | 17 +++++++++++++++++ command/util_test.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 command/agent_info_test.go create mode 100644 command/util_test.go diff --git a/command/agent_info_test.go b/command/agent_info_test.go new file mode 100644 index 000000000..4552b5cac --- /dev/null +++ b/command/agent_info_test.go @@ -0,0 +1,17 @@ +package command + +import ( + "testing" + + "github.com/mitchellh/cli" +) + +func TestAgentInfoCommand_Implements(t *testing.T) { + var _ cli.Command = &AgentInfoCommand{} +} + +func TestAgentInfoCommand_Run(t *testing.T) { + agent := testAgent(t) + defer agent.Shutdown() + println("yay") +} diff --git a/command/util_test.go b/command/util_test.go new file mode 100644 index 000000000..cfbb5ba63 --- /dev/null +++ b/command/util_test.go @@ -0,0 +1,37 @@ +package command + +import ( + "sync/atomic" + "testing" + + "github.com/hashicorp/nomad/command/agent" +) + +var offset uint64 + +func nextConfig() *agent.Config { + idx := int(atomic.AddUint64(&offset, 1)) + conf := agent.DefaultConfig() + + conf.Region = "region1" + conf.Datacenter = "dc1" + conf.NodeName = fmt.Sprintf("node%d", idx) + conf.BindAddr = "127.0.0.1" + conf.Server.Bootstrap = true + conf.Server.Enabled = true + conf.Client.Enabled = false + conf.Ports.HTTP = 30000 + idx + conf.Ports.Serf = 32000 + idx + conf.Ports.RPC = 31000 + idx + + return conf +} + +func testAgent(t *testing.T) *agent.Agent { + conf := nextConfig() + agent, err := agent.Create(conf) + if err != nil { + t.Fatalf("err: %s", err) + } + return agent +}