Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b8809dcd
Unverified
Commit
b8809dcd
authored
Jul 31, 2018
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for newline in command, arg, and env
parent
dca79aad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
describe_test.go
pkg/printers/internalversion/describe_test.go
+21
-19
No files found.
pkg/printers/internalversion/describe_test.go
View file @
b8809dcd
...
@@ -465,14 +465,12 @@ func VerifyDatesInOrder(
...
@@ -465,14 +465,12 @@ func VerifyDatesInOrder(
func
TestDescribeContainers
(
t
*
testing
.
T
)
{
func
TestDescribeContainers
(
t
*
testing
.
T
)
{
trueVal
:=
true
trueVal
:=
true
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
name
string
container
api
.
Container
container
api
.
Container
status
api
.
ContainerStatus
status
api
.
ContainerStatus
expectedElements
[]
string
expectedElements
[]
string
}{
}{
// Running state.
// Running state.
{
{
name
:
"test1"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -488,7 +486,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -488,7 +486,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// Waiting state.
// Waiting state.
{
{
name
:
"test2"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -504,7 +501,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -504,7 +501,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// Terminated state.
// Terminated state.
{
{
name
:
"test3"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -523,7 +519,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -523,7 +519,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// Last Terminated
// Last Terminated
{
{
name
:
"test4"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -547,7 +542,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -547,7 +542,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// No state defaults to waiting.
// No state defaults to waiting.
{
{
name
:
"test5"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -558,7 +552,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -558,7 +552,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// Env
// Env
{
{
name
:
"test6"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
ConfigMapRef
:
&
api
.
ConfigMapEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
ConfigMapRef
:
&
api
.
ConfigMapEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -568,7 +561,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -568,7 +561,6 @@ func TestDescribeContainers(t *testing.T) {
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
ConfigMap
\t
Optional: false"
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
ConfigMap
\t
Optional: false"
},
},
},
{
{
name
:
"test7"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
Prefix
:
"p_"
,
ConfigMapRef
:
&
api
.
ConfigMapEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
Prefix
:
"p_"
,
ConfigMapRef
:
&
api
.
ConfigMapEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -578,7 +570,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -578,7 +570,6 @@ func TestDescribeContainers(t *testing.T) {
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
ConfigMap with prefix 'p_'
\t
Optional: false"
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
ConfigMap with prefix 'p_'
\t
Optional: false"
},
},
},
{
{
name
:
"test8"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
ConfigMapRef
:
&
api
.
ConfigMapEnvSource
{
Optional
:
&
trueVal
,
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
ConfigMapRef
:
&
api
.
ConfigMapEnvSource
{
Optional
:
&
trueVal
,
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -588,7 +579,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -588,7 +579,6 @@ func TestDescribeContainers(t *testing.T) {
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
ConfigMap
\t
Optional: true"
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
ConfigMap
\t
Optional: true"
},
},
},
{
{
name
:
"test9"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
SecretRef
:
&
api
.
SecretEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
},
Optional
:
&
trueVal
}}}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
SecretRef
:
&
api
.
SecretEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
},
Optional
:
&
trueVal
}}}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -598,7 +588,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -598,7 +588,6 @@ func TestDescribeContainers(t *testing.T) {
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
Secret
\t
Optional: true"
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"envname"
,
"xyz"
,
"a123
\t
Secret
\t
Optional: true"
},
},
},
{
{
name
:
"test10"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
Prefix
:
"p_"
,
SecretRef
:
&
api
.
SecretEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Env
:
[]
api
.
EnvVar
{{
Name
:
"envname"
,
Value
:
"xyz"
}},
EnvFrom
:
[]
api
.
EnvFromSource
{{
Prefix
:
"p_"
,
SecretRef
:
&
api
.
SecretEnvSource
{
LocalObjectReference
:
api
.
LocalObjectReference
{
Name
:
"a123"
}}}}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -609,7 +598,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -609,7 +598,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// Command
// Command
{
{
name
:
"test11"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Command
:
[]
string
{
"sleep"
,
"1000"
}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Command
:
[]
string
{
"sleep"
,
"1000"
}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -618,9 +606,18 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -618,9 +606,18 @@ func TestDescribeContainers(t *testing.T) {
},
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"sleep"
,
"1000"
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"sleep"
,
"1000"
},
},
},
// Command with newline
{
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Command
:
[]
string
{
"sleep"
,
"1000
\n
2000"
}},
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Ready
:
true
,
RestartCount
:
7
,
},
expectedElements
:
[]
string
{
"1000
\n
2000"
},
},
// Args
// Args
{
{
name
:
"test12"
,
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Args
:
[]
string
{
"time"
,
"1000"
}},
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Args
:
[]
string
{
"time"
,
"1000"
}},
status
:
api
.
ContainerStatus
{
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -629,9 +626,18 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -629,9 +626,18 @@ func TestDescribeContainers(t *testing.T) {
},
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"time"
,
"1000"
},
expectedElements
:
[]
string
{
"test"
,
"State"
,
"Waiting"
,
"Ready"
,
"True"
,
"Restart Count"
,
"7"
,
"Image"
,
"image"
,
"time"
,
"1000"
},
},
},
// Args with newline
{
container
:
api
.
Container
{
Name
:
"test"
,
Image
:
"image"
,
Args
:
[]
string
{
"time"
,
"1000
\n
2000"
}},
status
:
api
.
ContainerStatus
{
Name
:
"test"
,
Ready
:
true
,
RestartCount
:
7
,
},
expectedElements
:
[]
string
{
"1000
\n
2000"
},
},
// Using limits.
// Using limits.
{
{
name
:
"test13"
,
container
:
api
.
Container
{
container
:
api
.
Container
{
Name
:
"test"
,
Name
:
"test"
,
Image
:
"image"
,
Image
:
"image"
,
...
@@ -652,7 +658,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -652,7 +658,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// Using requests.
// Using requests.
{
{
name
:
"test14"
,
container
:
api
.
Container
{
container
:
api
.
Container
{
Name
:
"test"
,
Name
:
"test"
,
Image
:
"image"
,
Image
:
"image"
,
...
@@ -668,7 +673,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -668,7 +673,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// volumeMounts read/write
// volumeMounts read/write
{
{
name
:
"test15"
,
container
:
api
.
Container
{
container
:
api
.
Container
{
Name
:
"test"
,
Name
:
"test"
,
Image
:
"image"
,
Image
:
"image"
,
...
@@ -683,7 +687,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -683,7 +687,6 @@ func TestDescribeContainers(t *testing.T) {
},
},
// volumeMounts readonly
// volumeMounts readonly
{
{
name
:
"test16"
,
container
:
api
.
Container
{
container
:
api
.
Container
{
Name
:
"test"
,
Name
:
"test"
,
Image
:
"image"
,
Image
:
"image"
,
...
@@ -700,7 +703,6 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -700,7 +703,6 @@ func TestDescribeContainers(t *testing.T) {
// volumeDevices
// volumeDevices
{
{
name
:
"test17"
,
container
:
api
.
Container
{
container
:
api
.
Container
{
Name
:
"test"
,
Name
:
"test"
,
Image
:
"image"
,
Image
:
"image"
,
...
@@ -716,7 +718,7 @@ func TestDescribeContainers(t *testing.T) {
...
@@ -716,7 +718,7 @@ func TestDescribeContainers(t *testing.T) {
}
}
for
i
,
testCase
:=
range
testCases
{
for
i
,
testCase
:=
range
testCases
{
t
.
Run
(
testCase
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"%d"
,
i
)
,
func
(
t
*
testing
.
T
)
{
out
:=
new
(
bytes
.
Buffer
)
out
:=
new
(
bytes
.
Buffer
)
pod
:=
api
.
Pod
{
pod
:=
api
.
Pod
{
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment