(t *testing.T)
| 106 | } |
| 107 | |
| 108 | func TestBoolWithInverseAction(t *testing.T) { |
| 109 | err := fmt.Errorf("action called") |
| 110 | flagMethod := func() *BoolWithInverseFlag { |
| 111 | bif := &BoolWithInverseFlag{ |
| 112 | Name: "env", |
| 113 | |
| 114 | // Setting env to the opposite to test flag Action is working as intended |
| 115 | Action: func(_ context.Context, cmd *Command, value bool) error { |
| 116 | return err |
| 117 | }, |
| 118 | } |
| 119 | return bif |
| 120 | } |
| 121 | |
| 122 | testCases := []*boolWithInverseTestCase{ |
| 123 | { |
| 124 | args: []string{"--no-env"}, |
| 125 | toBeSet: true, |
| 126 | value: false, |
| 127 | err: err, |
| 128 | }, |
| 129 | { |
| 130 | args: []string{"--env"}, |
| 131 | toBeSet: true, |
| 132 | value: true, |
| 133 | err: err, |
| 134 | }, |
| 135 | |
| 136 | // This test is not inverse because the flag action is never called |
| 137 | { |
| 138 | toBeSet: false, |
| 139 | value: false, |
| 140 | }, |
| 141 | { |
| 142 | args: []string{"--env", "--no-env"}, |
| 143 | err: errBothEnvFlagsAreSet, |
| 144 | }, |
| 145 | } |
| 146 | |
| 147 | errr := runBoolWithInverseFlagTests(t, flagMethod, testCases) |
| 148 | if errr != nil { |
| 149 | t.Error(errr) |
| 150 | return |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func TestBoolWithInverseAlias(t *testing.T) { |
| 155 | flagMethod := func() *BoolWithInverseFlag { |
nothing calls this directly
no test coverage detected