(t *testing.T, flagWithInverse *BoolWithInverseFlag)
| 20 | } |
| 21 | |
| 22 | func (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 | |
| 48 | func runBoolWithInverseFlagTests(t *testing.T, newFlagMethod func() *BoolWithInverseFlag, cases []*boolWithInverseTestCase) error { |
| 49 | for _, tc := range cases { |
no test coverage detected