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

Function TestBoolWithInverseEnvVars

flag_bool_with_inverse_test.go:190–252  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestBoolWithInverseEnvVars(t *testing.T) {
191 flagMethod := func() *BoolWithInverseFlag {
192 return &BoolWithInverseFlag{
193 Name: "env",
194 Sources: EnvVars("ENV", "NO-ENV"),
195 Local: true,
196 }
197 }
198
199 testCases := []*boolWithInverseTestCase{
200 {
201 toBeSet: true,
202 value: false,
203 envVars: map[string]string{
204 "NO-ENV": "false",
205 },
206 },
207 {
208 toBeSet: true,
209 value: true,
210 envVars: map[string]string{
211 "ENV": "true",
212 },
213 },
214 {
215 toBeSet: true,
216 value: false,
217 envVars: map[string]string{
218 "ENV": "false",
219 },
220 },
221 {
222 toBeSet: false,
223 value: false,
224 },
225 // TODO
226 /*{
227 err: errBothEnvFlagsAreSet,
228 envVars: map[string]string{
229 "ENV": "true",
230 "NO-ENV": "true",
231 },
232 },*/
233 {
234 err: fmt.Errorf("could not parse \"true_env\" as bool value from environment variable \"ENV\" for flag env: parse error"),
235 envVars: map[string]string{
236 "ENV": "true_env",
237 },
238 },
239 {
240 err: fmt.Errorf("could not parse \"false_env\" as bool value from environment variable \"NO-ENV\" for flag env: parse error"),
241 envVars: map[string]string{
242 "NO-ENV": "false_env",
243 },
244 },
245 }
246
247 err := runBoolWithInverseFlagTests(t, flagMethod, testCases)

Callers

nothing calls this directly

Calls 3

EnvVarsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…