MCPcopy
hub / github.com/urfave/cli / TestSuggestFlagFromError

Function TestSuggestFlagFromError

suggestions_test.go:70–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestSuggestFlagFromError(t *testing.T) {
71 // Given
72 app := buildExtendedTestCommand()
73
74 for _, testCase := range []struct {
75 command, provided, expected string
76 }{
77 {"", "hel", "--help"},
78 {"", "soccer", "--socket"},
79 {"config", "anot", "--another-flag"},
80 } {
81 // When
82 res, _ := app.suggestFlagFromError(
83 errors.New(providedButNotDefinedErrMsg+testCase.provided),
84 testCase.command,
85 )
86
87 // Then
88 assert.Equal(t, fmt.Sprintf(SuggestDidYouMeanTemplate+"\n\n", testCase.expected), res)
89 }
90}
91
92func TestSuggestFlagFromErrorWrongError(t *testing.T) {
93 // Given

Callers

nothing calls this directly

Calls 2

buildExtendedTestCommandFunction · 0.85
suggestFlagFromErrorMethod · 0.80

Tested by

no test coverage detected