MCPcopy
hub / github.com/kubernetes/kubectl / TestCompleteAndValidate

Function TestCompleteAndValidate

pkg/cmd/debug/debug_test.go:2571–2981  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2569}
2570
2571func 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",

Callers

nothing calls this directly

Calls 10

CompleteMethod · 0.95
ValidateMethod · 0.95
AddFlagsMethod · 0.95
NewDebugOptionsFunction · 0.85
WithNamespaceMethod · 0.80
DiffMethod · 0.80
StringMethod · 0.65
ExecuteMethod · 0.65
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…