Skip to content

Commit

Permalink
Increase test coverage for suggestions.go
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
  • Loading branch information
saschagrunert committed Dec 8, 2019
1 parent 58b52b6 commit cb1ce55
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion suggestions_test.go
Expand Up @@ -17,7 +17,7 @@ func TestSuggestFlag(t *testing.T) {
{"a", "--another-flag"},
{"hlp", "--help"},
{"k", ""},
{"soccer", "--socket"},
{"s", "-s"},
} {
// When
res := app.suggestFlag(app.Flags, testCase.provided)
Expand Down Expand Up @@ -61,6 +61,45 @@ func TestSuggestFlagFromError(t *testing.T) {
}
}

func TestSuggestFlagFromErrorWrongError(t *testing.T) {
// Given
app := testApp()

// When
_, err := app.suggestFlagFromError(errors.New("invalid"), "")

// Then
expect(t, true, err != nil)
}

func TestSuggestFlagFromErrorWrongCommand(t *testing.T) {
// Given
app := testApp()

// When
_, err := app.suggestFlagFromError(
errors.New(providedButNotDefinedErrMsg+"flag"),
"invalid",
)

// Then
expect(t, true, err != nil)
}

func TestSuggestFlagFromErrorNoSuggestion(t *testing.T) {
// Given
app := testApp()

// When
_, err := app.suggestFlagFromError(
errors.New(providedButNotDefinedErrMsg+""),
"",
)

// Then
expect(t, true, err != nil)
}

func TestSuggestCommand(t *testing.T) {
// Given
app := testApp()
Expand Down

0 comments on commit cb1ce55

Please sign in to comment.