|
|
|
@ -15,7 +15,7 @@ import (
|
|
|
|
|
|
|
|
|
|
func argFail(t *testing.T, args []string, expected string) { |
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
c.flags.SetOutput(ui.ErrorWriter) |
|
|
|
|
if code := c.Run(args); code != 1 { |
|
|
|
|
t.Fatalf("expected return code 1, got %d", code) |
|
|
|
@ -28,7 +28,7 @@ func argFail(t *testing.T, args []string, expected string) {
|
|
|
|
|
|
|
|
|
|
func TestLockCommand_noTabs(t *testing.T) { |
|
|
|
|
t.Parallel() |
|
|
|
|
if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { |
|
|
|
|
if strings.ContainsRune(New(cli.NewMockUi(), nil).Help(), '\t') { |
|
|
|
|
t.Fatal("help has tabs") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -48,7 +48,7 @@ func TestLockCommand(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "test/prefix", "touch", filePath} |
|
|
|
@ -73,7 +73,7 @@ func TestLockCommand_NoShell(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "-shell=false", "test/prefix", "touch", filePath} |
|
|
|
@ -98,7 +98,7 @@ func TestLockCommand_TryLock(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "-try=10s", "test/prefix", "touch", filePath} |
|
|
|
@ -132,7 +132,7 @@ func TestLockCommand_TrySemaphore(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "-n=3", "-try=10s", "test/prefix", "touch", filePath} |
|
|
|
@ -166,7 +166,7 @@ func TestLockCommand_MonitorRetry_Lock_Default(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "test/prefix", "touch", filePath} |
|
|
|
@ -201,7 +201,7 @@ func TestLockCommand_MonitorRetry_Semaphore_Default(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "-n=3", "test/prefix", "touch", filePath} |
|
|
|
@ -236,7 +236,7 @@ func TestLockCommand_MonitorRetry_Lock_Arg(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "-monitor-retry=9", "test/prefix", "touch", filePath} |
|
|
|
@ -271,7 +271,7 @@ func TestLockCommand_MonitorRetry_Semaphore_Arg(t *testing.T) {
|
|
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1") |
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(a.Config.DataDir, "test_touch") |
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr(), "-n=3", "-monitor-retry=9", "test/prefix", "touch", filePath} |
|
|
|
@ -330,7 +330,7 @@ func TestLockCommand_ChildExitCode(t *testing.T) {
|
|
|
|
|
for _, tc := range tt { |
|
|
|
|
t.Run(tc.name, func(t *testing.T) { |
|
|
|
|
ui := cli.NewMockUi() |
|
|
|
|
c := New(ui) |
|
|
|
|
c := New(ui, nil) |
|
|
|
|
|
|
|
|
|
if got := c.Run(tc.args); got != tc.want { |
|
|
|
|
t.Fatalf("got %d want %d", got, tc.want) |
|
|
|
|