github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/command/reload/reload_test.go (about) 1 package reload 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/hashicorp/consul/agent" 8 "github.com/mitchellh/cli" 9 ) 10 11 func TestReloadCommand_noTabs(t *testing.T) { 12 t.Parallel() 13 if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { 14 t.Fatal("help has tabs") 15 } 16 } 17 18 func TestReloadCommand(t *testing.T) { 19 t.Parallel() 20 a := agent.NewTestAgent(t, t.Name(), ``) 21 defer a.Shutdown() 22 23 // Setup a dummy response to errCh to simulate a successful reload 24 go func() { 25 errCh := <-a.ReloadCh() 26 errCh <- nil 27 }() 28 29 ui := cli.NewMockUi() 30 c := New(ui) 31 args := []string{"-http-addr=" + a.HTTPAddr()} 32 33 code := c.Run(args) 34 if code != 0 { 35 t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) 36 } 37 38 if !strings.Contains(ui.OutputWriter.String(), "reload triggered") { 39 t.Fatalf("bad: %#v", ui.OutputWriter.String()) 40 } 41 }