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
056d5868
Commit
056d5868
authored
Aug 31, 2017
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make these tests table-driven
parent
a0eb194d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
34 deletions
+50
-34
utils_test.go
pkg/controller/job/utils_test.go
+50
-34
No files found.
pkg/controller/job/utils_test.go
View file @
056d5868
...
...
@@ -24,43 +24,59 @@ import (
)
func
TestIsJobFinished
(
t
*
testing
.
T
)
{
job
:=
&
batch
.
Job
{
Status
:
batch
.
JobStatus
{
Conditions
:
[]
batch
.
JobCondition
{{
Type
:
batch
.
JobComplete
,
Status
:
v1
.
ConditionTrue
,
}},
testCases
:=
map
[
string
]
struct
{
conditionType
batch
.
JobConditionType
conditionStatus
v1
.
ConditionStatus
expectJobNotFinished
bool
}{
"Job is completed and condition is true"
:
{
batch
.
JobComplete
,
v1
.
ConditionTrue
,
false
,
},
"Job is completed and condition is false"
:
{
batch
.
JobComplete
,
v1
.
ConditionFalse
,
true
,
},
"Job is completed and condition is unknown"
:
{
batch
.
JobComplete
,
v1
.
ConditionUnknown
,
true
,
},
"Job is failed and condition is true"
:
{
batch
.
JobFailed
,
v1
.
ConditionTrue
,
false
,
},
"Job is failed and condition is false"
:
{
batch
.
JobFailed
,
v1
.
ConditionFalse
,
true
,
},
"Job is failed and condition is unknown"
:
{
batch
.
JobFailed
,
v1
.
ConditionUnknown
,
true
,
},
}
if
!
IsJobFinished
(
job
)
{
t
.
Error
(
"Job was expected to be finished"
)
}
job
.
Status
.
Conditions
[
0
]
.
Status
=
v1
.
ConditionFalse
if
IsJobFinished
(
job
)
{
t
.
Error
(
"Job was not expected to be finished"
)
}
job
.
Status
.
Conditions
[
0
]
.
Status
=
v1
.
ConditionUnknown
if
IsJobFinished
(
job
)
{
t
.
Error
(
"Job was not expected to be finished"
)
}
job
.
Status
.
Conditions
[
0
]
.
Type
=
batch
.
JobFailed
job
.
Status
.
Conditions
[
0
]
.
Status
=
v1
.
ConditionTrue
if
!
IsJobFinished
(
job
)
{
t
.
Error
(
"Job was expected to be finished"
)
}
job
.
Status
.
Conditions
[
0
]
.
Status
=
v1
.
ConditionFalse
if
IsJobFinished
(
job
)
{
t
.
Error
(
"Job was not expected to be finished"
)
}
for
name
,
tc
:=
range
testCases
{
job
:=
&
batch
.
Job
{
Status
:
batch
.
JobStatus
{
Conditions
:
[]
batch
.
JobCondition
{{
Type
:
tc
.
conditionType
,
Status
:
tc
.
conditionStatus
,
}},
},
}
job
.
Status
.
Conditions
[
0
]
.
Status
=
v1
.
ConditionUnknown
if
IsJobFinished
(
job
)
{
t
.
Error
(
"Job was not expected to be finished"
)
if
tc
.
expectJobNotFinished
==
IsJobFinished
(
job
)
{
if
tc
.
expectJobNotFinished
{
t
.
Errorf
(
"test name: %s, job was not expected to be finished"
,
name
)
}
else
{
t
.
Errorf
(
"test name: %s, job was expected to be finished"
,
name
)
}
}
}
}
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