open-nomad/command/integration_test.go

35 lines
696 B
Go
Raw Normal View History

2017-03-03 20:30:25 +00:00
package command_test
import (
"io/ioutil"
"os"
"os/exec"
"testing"
)
func TestIntegration_Command_NomadInit(t *testing.T) {
2017-07-21 04:24:21 +00:00
t.Parallel()
2017-03-03 20:30:25 +00:00
tmpDir, err := ioutil.TempDir("", "nomadtest-rootsecretdir")
if err != nil {
t.Fatalf("unable to create tempdir for test: %v", err)
}
defer os.RemoveAll(tmpDir)
{
cmd := exec.Command("nomad", "init")
cmd.Dir = tmpDir
if err := cmd.Run(); err != nil {
t.Fatalf("error running init: %v", err)
}
}
{
cmd := exec.Command("nomad", "validate", "example.nomad")
cmd.Dir = tmpDir
2017-07-21 04:24:21 +00:00
cmd.Env = []string{`NOMAD_ADDR=http://127.0.0.1:0`}
2017-03-03 20:30:25 +00:00
if err := cmd.Run(); err != nil {
t.Fatalf("error validating example.nomad: %v", err)
}
}
}