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

Function TestGenerateDebugContainer

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

Source from the content-addressed store, hash-verified

34)
35
36func TestGenerateDebugContainer(t *testing.T) {
37 // Slightly less randomness for testing.
38 defer func(old func(int) string) { nameSuffixFunc = old }(nameSuffixFunc)
39 var suffixCounter int
40 nameSuffixFunc = func(int) string {
41 suffixCounter++
42 return fmt.Sprint(suffixCounter)
43 }
44
45 for _, tc := range []struct {
46 name string
47 opts *DebugOptions
48 pod *corev1.Pod
49 expected *corev1.EphemeralContainer
50 }{
51 {
52 name: "minimum fields",
53 opts: &DebugOptions{
54 Container: "debugger",
55 Image: "busybox",
56 PullPolicy: corev1.PullIfNotPresent,
57 Profile: ProfileLegacy,
58 },
59 expected: &corev1.EphemeralContainer{
60 EphemeralContainerCommon: corev1.EphemeralContainerCommon{
61 Name: "debugger",
62 Image: "busybox",
63 ImagePullPolicy: "IfNotPresent",
64 TerminationMessagePolicy: "File",
65 },
66 },
67 },
68 {
69 name: "namespace targeting",
70 opts: &DebugOptions{
71 Container: "debugger",
72 Image: "busybox",
73 PullPolicy: corev1.PullIfNotPresent,
74 TargetContainer: "myapp",
75 Profile: ProfileLegacy,
76 },
77 expected: &corev1.EphemeralContainer{
78 EphemeralContainerCommon: corev1.EphemeralContainerCommon{
79 Name: "debugger",
80 Image: "busybox",
81 ImagePullPolicy: "IfNotPresent",
82 TerminationMessagePolicy: "File",
83 },
84 TargetContainerName: "myapp",
85 },
86 },
87 {
88 name: "debug args as container command",
89 opts: &DebugOptions{
90 Args: []string{"/bin/echo", "one", "two", "three"},
91 Container: "debugger",
92 Image: "busybox",
93 PullPolicy: corev1.PullIfNotPresent,

Callers

nothing calls this directly

Calls 6

NewProfileApplierFunction · 0.85
ToMethod · 0.80
DiffMethod · 0.80
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…