(t *testing.T)
| 236 | } |
| 237 | |
| 238 | func TestAddCommandFlagInteractions(t *testing.T) { |
| 239 | tests := []struct { |
| 240 | name string |
| 241 | flagSetup func(cmd *cobra.Command) |
| 242 | expectValid bool |
| 243 | description string |
| 244 | }{ |
| 245 | { |
| 246 | name: "no-stop-after and stop-after together", |
| 247 | flagSetup: func(cmd *cobra.Command) { |
| 248 | cmd.Flags().Set("no-stop-after", "true") |
| 249 | cmd.Flags().Set("stop-after", "+48h") |
| 250 | }, |
| 251 | expectValid: true, // Both flags can be set, stop-after takes precedence |
| 252 | description: "Both no-stop-after and stop-after flags can be set", |
| 253 | }, |
| 254 | { |
| 255 | name: "create-pull-request and pr alias", |
| 256 | flagSetup: func(cmd *cobra.Command) { |
| 257 | cmd.Flags().Set("create-pull-request", "true") |
| 258 | cmd.Flags().Set("pr", "true") |
| 259 | }, |
| 260 | expectValid: true, // Both aliases should work |
| 261 | description: "Both create-pull-request and pr flags can be set (aliases)", |
| 262 | }, |
| 263 | { |
| 264 | name: "force flag with number", |
| 265 | flagSetup: func(cmd *cobra.Command) { |
| 266 | cmd.Flags().Set("force", "true") |
| 267 | cmd.Flags().Set("number", "3") |
| 268 | }, |
| 269 | expectValid: true, |
| 270 | description: "Force flag should work with multiple numbered copies", |
| 271 | }, |
| 272 | { |
| 273 | name: "dir flag with subdirectory", |
| 274 | flagSetup: func(cmd *cobra.Command) { |
| 275 | cmd.Flags().Set("dir", "shared") |
| 276 | }, |
| 277 | expectValid: true, |
| 278 | description: "Dir flag should accept subdirectory name", |
| 279 | }, |
| 280 | } |
| 281 | |
| 282 | for _, tt := range tests { |
| 283 | t.Run(tt.name, func(t *testing.T) { |
| 284 | cmd := NewAddCommand(validateEngineStub) |
| 285 | |
| 286 | // Apply flag setup |
| 287 | tt.flagSetup(cmd) |
| 288 | |
| 289 | // Verify flags are set correctly |
| 290 | flags := cmd.Flags() |
| 291 | assert.NotNil(t, flags, "Command flags should not be nil") |
| 292 | |
| 293 | // The actual validation happens during RunE execution |
| 294 | // Here we just verify the flags can be set without panic |
| 295 | assert.True(t, tt.expectValid, tt.description) |
nothing calls this directly
no test coverage detected