(t *testing.T)
| 2569 | } |
| 2570 | |
| 2571 | func TestCompleteAndValidate(t *testing.T) { |
| 2572 | tf := cmdtesting.NewTestFactory().WithNamespace("test") |
| 2573 | ioStreams, _, _, _ := genericiooptions.NewTestIOStreams() |
| 2574 | cmpFilter := cmp.FilterPath(func(p cmp.Path) bool { |
| 2575 | switch p.String() { |
| 2576 | // IOStreams contains unexported fields |
| 2577 | case "IOStreams", "Applier": |
| 2578 | return true |
| 2579 | } |
| 2580 | return false |
| 2581 | }, cmp.Ignore()) |
| 2582 | |
| 2583 | tests := []struct { |
| 2584 | name, args string |
| 2585 | wantOpts *DebugOptions |
| 2586 | wantError bool |
| 2587 | }{ |
| 2588 | { |
| 2589 | name: "No targets", |
| 2590 | args: "--image=image", |
| 2591 | wantError: true, |
| 2592 | }, |
| 2593 | { |
| 2594 | name: "Invalid environment variables", |
| 2595 | args: "--image=busybox --env=FOO mypod", |
| 2596 | wantError: true, |
| 2597 | }, |
| 2598 | { |
| 2599 | name: "Invalid image name", |
| 2600 | args: "--image=image:label@deadbeef mypod", |
| 2601 | wantError: true, |
| 2602 | }, |
| 2603 | { |
| 2604 | name: "Invalid pull policy", |
| 2605 | args: "--image=image --image-pull-policy=whenever-you-feel-like-it", |
| 2606 | wantError: true, |
| 2607 | }, |
| 2608 | { |
| 2609 | name: "TTY without stdin", |
| 2610 | args: "--image=image --tty", |
| 2611 | wantError: true, |
| 2612 | }, |
| 2613 | { |
| 2614 | name: "Set image pull policy", |
| 2615 | args: "--image=busybox --image-pull-policy=Always mypod", |
| 2616 | wantOpts: &DebugOptions{ |
| 2617 | Args: []string{}, |
| 2618 | Image: "busybox", |
| 2619 | KeepInitContainers: true, |
| 2620 | Namespace: "test", |
| 2621 | PullPolicy: corev1.PullPolicy("Always"), |
| 2622 | ShareProcesses: true, |
| 2623 | Profile: ProfileGeneral, |
| 2624 | TargetNames: []string{"mypod"}, |
| 2625 | }, |
| 2626 | }, |
| 2627 | { |
| 2628 | name: "Multiple targets", |
nothing calls this directly
no test coverage detected
searching dependent graphs…