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

Function TestBoolWithInverseWithPrefix

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

Source from the content-addressed store, hash-verified

252}
253
254func TestBoolWithInverseWithPrefix(t *testing.T) {
255 flagMethod := func() *BoolWithInverseFlag {
256 return &BoolWithInverseFlag{
257 Name: "env",
258 InversePrefix: "without-",
259 }
260 }
261
262 testCases := []*boolWithInverseTestCase{
263 {
264 args: []string{"--without-env"},
265 toBeSet: true,
266 value: false,
267 },
268 {
269 args: []string{"--env"},
270 toBeSet: true,
271 value: true,
272 },
273 {
274 toBeSet: false,
275 value: false,
276 },
277 {
278 args: []string{"--env", "--without-env"},
279 err: fmt.Errorf("cannot set both flags `--env` and `--without-env`"),
280 },
281 {
282 args: []string{"--without-env", "--env"},
283 err: fmt.Errorf("cannot set both flags `--env` and `--without-env`"),
284 },
285 }
286
287 err := runBoolWithInverseFlagTests(t, flagMethod, testCases)
288 if err != nil {
289 t.Error(err)
290 return
291 }
292}
293
294func TestBoolWithInverseRequired(t *testing.T) {
295 flagMethod := func() *BoolWithInverseFlag {

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected