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
3ef73bdb
Commit
3ef73bdb
authored
Jun 05, 2017
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unittest for PodList
parent
04acd91a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
printers_test.go
pkg/printers/internalversion/printers_test.go
+51
-0
No files found.
pkg/printers/internalversion/printers_test.go
View file @
3ef73bdb
...
@@ -1459,6 +1459,57 @@ func TestPrintPod(t *testing.T) {
...
@@ -1459,6 +1459,57 @@ func TestPrintPod(t *testing.T) {
}
}
}
}
func
TestPrintPodList
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
pods
api
.
PodList
expect
[]
metav1alpha1
.
TableRow
}{
// Test podList's pod: name, num of containers, restarts, container ready status
{
api
.
PodList
{
Items
:
[]
api
.
Pod
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test1"
},
Spec
:
api
.
PodSpec
{
Containers
:
make
([]
api
.
Container
,
2
)},
Status
:
api
.
PodStatus
{
Phase
:
"podPhase"
,
ContainerStatuses
:
[]
api
.
ContainerStatus
{
{
Ready
:
true
,
RestartCount
:
3
,
State
:
api
.
ContainerState
{
Running
:
&
api
.
ContainerStateRunning
{}}},
{
Ready
:
true
,
RestartCount
:
3
,
State
:
api
.
ContainerState
{
Running
:
&
api
.
ContainerStateRunning
{}}},
},
},
},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test2"
},
Spec
:
api
.
PodSpec
{
Containers
:
make
([]
api
.
Container
,
1
)},
Status
:
api
.
PodStatus
{
Phase
:
"podPhase"
,
ContainerStatuses
:
[]
api
.
ContainerStatus
{
{
Ready
:
true
,
RestartCount
:
1
,
State
:
api
.
ContainerState
{
Running
:
&
api
.
ContainerStateRunning
{}}},
},
},
},
},
},
[]
metav1alpha1
.
TableRow
{{
Cells
:
[]
interface
{}{
"test1"
,
"2/2"
,
"podPhase"
,
6
,
"<unknown>"
}},
{
Cells
:
[]
interface
{}{
"test2"
,
"1/1"
,
"podPhase"
,
1
,
"<unknown>"
}}},
},
}
for
_
,
test
:=
range
tests
{
rows
,
err
:=
printPodList
(
&
test
.
pods
,
printers
.
PrintOptions
{
ShowAll
:
true
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
for
i
:=
range
rows
{
rows
[
i
]
.
Object
.
Object
=
nil
}
if
!
reflect
.
DeepEqual
(
test
.
expect
,
rows
)
{
t
.
Errorf
(
"mismatch: %s"
,
diff
.
ObjectReflectDiff
(
test
.
expect
,
rows
))
}
}
}
func
TestPrintNonTerminatedPod
(
t
*
testing
.
T
)
{
func
TestPrintNonTerminatedPod
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
api
.
Pod
pod
api
.
Pod
...
...
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