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

Function TestCommandAttributeAccessing

command_test.go:4524–4584  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4522}
4523
4524func TestCommandAttributeAccessing(t *testing.T) {
4525 tdata := []struct {
4526 testCase string
4527 setBoolInput string
4528 ctxBoolInput string
4529 parent *Command
4530 }{
4531 {
4532 testCase: "empty",
4533 setBoolInput: "",
4534 ctxBoolInput: "",
4535 },
4536 {
4537 testCase: "empty_with_background_context",
4538 setBoolInput: "",
4539 ctxBoolInput: "",
4540 parent: &Command{},
4541 },
4542 {
4543 testCase: "empty_set_bool_and_present_ctx_bool",
4544 setBoolInput: "",
4545 ctxBoolInput: "ctx-bool",
4546 },
4547 {
4548 testCase: "present_set_bool_and_present_ctx_bool_with_background_context",
4549 setBoolInput: "",
4550 ctxBoolInput: "ctx-bool",
4551 parent: &Command{},
4552 },
4553 {
4554 testCase: "present_set_bool_and_present_ctx_bool",
4555 setBoolInput: "ctx-bool",
4556 ctxBoolInput: "ctx-bool",
4557 },
4558 {
4559 testCase: "present_set_bool_and_present_ctx_bool_with_background_context",
4560 setBoolInput: "ctx-bool",
4561 ctxBoolInput: "ctx-bool",
4562 parent: &Command{},
4563 },
4564 {
4565 testCase: "present_set_bool_and_different_ctx_bool",
4566 setBoolInput: "ctx-bool",
4567 ctxBoolInput: "not-ctx-bool",
4568 },
4569 {
4570 testCase: "present_set_bool_and_different_ctx_bool_with_background_context",
4571 setBoolInput: "ctx-bool",
4572 ctxBoolInput: "not-ctx-bool",
4573 parent: &Command{},
4574 },
4575 }
4576
4577 for _, test := range tdata {
4578 t.Run(test.testCase, func(t *testing.T) {
4579 cmd := &Command{parent: test.parent}
4580
4581 require.False(t, cmd.Bool(test.ctxBoolInput))

Callers

nothing calls this directly

Calls 2

BoolMethod · 0.95
RunMethod · 0.45

Tested by

no test coverage detected