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

Method Run

flag_bool_with_inverse_test.go:22–46  ·  view source on GitHub ↗
(t *testing.T, flagWithInverse *BoolWithInverseFlag)

Source from the content-addressed store, hash-verified

20}
21
22func (tc *boolWithInverseTestCase) Run(t *testing.T, flagWithInverse *BoolWithInverseFlag) error {
23 cmd := &Command{
24 Flags: []Flag{flagWithInverse},
25 Action: func(context.Context, *Command) error { return nil },
26 }
27
28 for key, val := range tc.envVars {
29 t.Setenv(key, val)
30 }
31
32 err := cmd.Run(buildTestContext(t), append([]string{"prog"}, tc.args...))
33 if err != nil {
34 return err
35 }
36
37 if flagWithInverse.IsSet() != tc.toBeSet {
38 return fmt.Errorf("flag should be set %t, but got %t", tc.toBeSet, flagWithInverse.IsSet())
39 }
40
41 if flagWithInverse.Get() != tc.value {
42 return fmt.Errorf("flag value should be %t, but got %t", tc.value, flagWithInverse.Get())
43 }
44
45 return nil
46}
47
48func runBoolWithInverseFlagTests(t *testing.T, newFlagMethod func() *BoolWithInverseFlag, cases []*boolWithInverseTestCase) error {
49 for _, tc := range cases {

Callers 3

Calls 4

RunMethod · 0.95
buildTestContextFunction · 0.85
IsSetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected