Debian Codegraph @

suggestions_test.go

raw symbols SCIP
1 package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/
2
3 import (
4 "errorsscip-go gomod github.com/golang/go/src go1.22 errors/"
5 "fmtscip-go gomod github.com/golang/go/src go1.22 fmt/"
6 "testingscip-go gomod github.com/golang/go/src go1.22 testing/"
7
8 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
9 )
10
11 func TestJaroWinklerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestJaroWinkler().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
12 // Given
13 for _, testCase := range []struct {
14 a, b string
15 expected float64
16 }{
17 {"", "", 1},
18 {"a", "", 0},
19 {"", "a", 0},
20 {"a", "a", 1},
21 {"a", "b", 0},
22 {"aa", "aa", 1},
23 {"aa", "bb", 0},
24 {"aaa", "aaa", 1},
25 {"aa", "ab", 0.6666666666666666},
26 {"aa", "ba", 0.6666666666666666},
27 {"ba", "aa", 0.6666666666666666},
28 {"ab", "aa", 0.6666666666666666},
29 } {
30 // When
31 res := jaroWinklerscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/jaroWinkler().(testCase.a, testCase.b)
32
33 // Then
34 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, testCase.expected, res)
35 }
36 }
37
38 func TestSuggestFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestFlag().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
39 // Given
40 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
41
42 for _, testCase := range []struct {
43 provided, expected string
44 }{
45 {"", ""},
46 {"a", "--another-flag"},
47 {"hlp", "--help"},
48 {"k", ""},
49 {"s", "-s"},
50 } {
51 // When
52 res := suggestFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/suggestFlag().(app.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags., testCase.provided, false)
53
54 // Then
55 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, testCase.expected, res)
56 }
57 }
58
59 func TestSuggestFlagHideHelpscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestFlagHideHelp().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
60 // Given
61 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
62
63 // When
64 res := suggestFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/suggestFlag().(app.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags., "hlp", true)
65
66 // Then
67 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "--fl", res)
68 }
69
70 func TestSuggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestFlagFromError().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
71 // Given
72 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/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.suggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#suggestFlagFromError().(
83 errorsscip-go gomod github.com/golang/go/src go1.22 errors/.Newscip-go gomod github.com/golang/go/src go1.22 errors/New().(providedButNotDefinedErrMsgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/providedButNotDefinedErrMsg.+testCase.provided),
84 testCase.command,
85 )
86
87 // Then
88 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().(SuggestDidYouMeanTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/SuggestDidYouMeanTemplate.+"\n\n", testCase.expected), res)
89 }
90 }
91
92 func TestSuggestFlagFromErrorWrongErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestFlagFromErrorWrongError().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
93 // Given
94 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
95
96 // When
97 _, err := app.suggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#suggestFlagFromError().(errorsscip-go gomod github.com/golang/go/src go1.22 errors/.Newscip-go gomod github.com/golang/go/src go1.22 errors/New().("invalid"), "")
98
99 // Then
100 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Error().(t, err)
101 }
102
103 func TestSuggestFlagFromErrorWrongCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestFlagFromErrorWrongCommand().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
104 // Given
105 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
106
107 // When
108 _, err := app.suggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#suggestFlagFromError().(
109 errorsscip-go gomod github.com/golang/go/src go1.22 errors/.Newscip-go gomod github.com/golang/go/src go1.22 errors/New().(providedButNotDefinedErrMsgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/providedButNotDefinedErrMsg.+"flag"),
110 "invalid",
111 )
112
113 // Then
114 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Error().(t, err)
115 }
116
117 func TestSuggestFlagFromErrorNoSuggestionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestFlagFromErrorNoSuggestion().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
118 // Given
119 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
120
121 // When
122 _, err := app.suggestFlagFromErrorscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#suggestFlagFromError().(
123 errorsscip-go gomod github.com/golang/go/src go1.22 errors/.Newscip-go gomod github.com/golang/go/src go1.22 errors/New().(providedButNotDefinedErrMsgscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/providedButNotDefinedErrMsg.+""),
124 "",
125 )
126
127 // Then
128 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Error().(t, err)
129 }
130
131 func TestSuggestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestSuggestCommand().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
132 // Given
133 app := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
134
135 for _, testCase := range []struct {
136 provided, expected string
137 }{
138 {"", ""},
139 {"conf", "config"},
140 {"i", "i"},
141 {"information", "info"},
142 {"inf", "info"},
143 {"con", "config"},
144 {"not-existing", "info"},
145 } {
146 // When
147 res := suggestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/suggestCommand().(app.Commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Commands., testCase.provided)
148
149 // Then
150 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, testCase.expected, res)
151 }
152 }