-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cli | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestArgumentGetters(t *testing.T) { | ||
t.Run("returns the name", func(t *testing.T) { | ||
argument := Argument{Name: "Foo"} | ||
want := "Foo" | ||
got := argument.GetName() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns the label", func(t *testing.T) { | ||
argument := Argument{Name: "Foo"} | ||
want := "Foo:" | ||
got := argument.GetLabel() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns the help", func(t *testing.T) { | ||
argument := Argument{Help: "Foo"} | ||
want := "Foo" | ||
got := argument.GetHelp() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns that the argument is required", func(t *testing.T) { | ||
argument := Argument{} | ||
want := true | ||
got := argument.GetIsRequired() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cli | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFlagGetters(t *testing.T) { | ||
t.Run("returns the name", func(t *testing.T) { | ||
flag := Flag{Name: "Foo"} | ||
want := "Foo" | ||
got := flag.GetName() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns the label", func(t *testing.T) { | ||
flag := Flag{Name: "Foo"} | ||
want := "Foo:" | ||
got := flag.GetLabel() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns the help", func(t *testing.T) { | ||
flag := Flag{Help: "Foo"} | ||
want := "Foo" | ||
got := flag.GetHelp() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns that the flag is required", func(t *testing.T) { | ||
flag := Flag{IsRequired: true} | ||
want := true | ||
got := flag.GetIsRequired() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns that the flag is not required", func(t *testing.T) { | ||
flag := Flag{IsRequired: false} | ||
want := false | ||
got := flag.GetIsRequired() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cli | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPickerOptions(t *testing.T) { | ||
t.Run("returns the labels", func(t *testing.T) { | ||
options := pickerOptions{pickerOption{label: "Foo"}, pickerOption{label: "Bar"}} | ||
want := []string{"Foo", "Bar"} | ||
got := options.labels() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns the default label", func(t *testing.T) { | ||
options := pickerOptions{pickerOption{label: "Foo"}, pickerOption{label: "Bar"}} | ||
want := "Foo" | ||
got := options.defaultLabel() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns an empty label when there are no options", func(t *testing.T) { | ||
options := pickerOptions{} | ||
want := "" | ||
got := options.defaultLabel() | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns the value for a given label", func(t *testing.T) { | ||
options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}} | ||
want := "1" | ||
got := options.getValue("Bar") | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
|
||
t.Run("returns an empty value given a non-existent label", func(t *testing.T) { | ||
options := pickerOptions{pickerOption{label: "Foo"}} | ||
want := "" | ||
got := options.getValue("Bar") | ||
|
||
assert.Equal(t, want, got) | ||
}) | ||
} |