(t *testing.T)
| 6192 | } |
| 6193 | |
| 6194 | func TestFlagEqualsEmptyValue(t *testing.T) { |
| 6195 | t.Run("--flag= sets empty string", func(t *testing.T) { |
| 6196 | var val string |
| 6197 | |
| 6198 | cmd := &Command{ |
| 6199 | Flags: []Flag{ |
| 6200 | &StringFlag{ |
| 6201 | Name: "name", |
| 6202 | Destination: &val, |
| 6203 | }, |
| 6204 | }, |
| 6205 | } |
| 6206 | |
| 6207 | err := cmd.Run(buildTestContext(t), []string{"app", "--name="}) |
| 6208 | assert.NoError(t, err) |
| 6209 | assert.Equal(t, "", val) |
| 6210 | }) |
| 6211 | |
| 6212 | t.Run("--flag= does not consume next positional arg", func(t *testing.T) { |
| 6213 | var val string |
| 6214 | var args []string |
| 6215 | |
| 6216 | cmd := &Command{ |
| 6217 | Flags: []Flag{ |
| 6218 | &StringFlag{ |
| 6219 | Name: "name", |
| 6220 | Destination: &val, |
| 6221 | }, |
| 6222 | }, |
| 6223 | Action: func(_ context.Context, cmd *Command) error { |
| 6224 | args = cmd.Args().Slice() |
| 6225 | return nil |
| 6226 | }, |
| 6227 | } |
| 6228 | |
| 6229 | err := cmd.Run(buildTestContext(t), []string{"app", "--name=", "positional"}) |
| 6230 | assert.NoError(t, err) |
| 6231 | assert.Equal(t, "", val) |
| 6232 | assert.Equal(t, []string{"positional"}, args) |
| 6233 | }) |
| 6234 | } |
| 6235 | |
| 6236 | // TestCommand_NoDefaultCmdArgMatchingFlag tests the argument set |
| 6237 | // of a command which has no default command, and has a flag with |
nothing calls this directly
no test coverage detected