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
808c3938
Commit
808c3938
authored
Apr 02, 2018
by
hangaoshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test for new function AnnotationsNeedUpdate
parent
1fa06a6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
deployment_util_test.go
pkg/controller/deployment/util/deployment_util_test.go
+74
-0
No files found.
pkg/controller/deployment/util/deployment_util_test.go
View file @
808c3938
...
@@ -1265,3 +1265,77 @@ func TestAnnotationUtils(t *testing.T) {
...
@@ -1265,3 +1265,77 @@ func TestAnnotationUtils(t *testing.T) {
})
})
//Tear Down
//Tear Down
}
}
func
TestReplicasAnnotationsNeedUpdate
(
t
*
testing
.
T
)
{
desiredReplicas
:=
fmt
.
Sprintf
(
"%d"
,
int32
(
10
))
maxReplicas
:=
fmt
.
Sprintf
(
"%d"
,
int32
(
20
))
tests
:=
[]
struct
{
name
string
replicaSet
*
extensions
.
ReplicaSet
expected
bool
}{
{
name
:
"test Annotations nil"
,
replicaSet
:
&
extensions
.
ReplicaSet
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"hello"
,
Namespace
:
"test"
},
Spec
:
extensions
.
ReplicaSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}},
},
},
expected
:
true
,
},
{
name
:
"test desiredReplicas update"
,
replicaSet
:
&
extensions
.
ReplicaSet
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"hello"
,
Namespace
:
"test"
,
Annotations
:
map
[
string
]
string
{
DesiredReplicasAnnotation
:
"8"
,
MaxReplicasAnnotation
:
maxReplicas
},
},
Spec
:
extensions
.
ReplicaSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}},
},
},
expected
:
true
,
},
{
name
:
"test maxReplicas update"
,
replicaSet
:
&
extensions
.
ReplicaSet
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"hello"
,
Namespace
:
"test"
,
Annotations
:
map
[
string
]
string
{
DesiredReplicasAnnotation
:
desiredReplicas
,
MaxReplicasAnnotation
:
"16"
},
},
Spec
:
extensions
.
ReplicaSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}},
},
},
expected
:
true
,
},
{
name
:
"test needn't update"
,
replicaSet
:
&
extensions
.
ReplicaSet
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"hello"
,
Namespace
:
"test"
,
Annotations
:
map
[
string
]
string
{
DesiredReplicasAnnotation
:
desiredReplicas
,
MaxReplicasAnnotation
:
maxReplicas
},
},
Spec
:
extensions
.
ReplicaSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}},
},
},
expected
:
false
,
},
}
for
i
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
result
:=
ReplicasAnnotationsNeedUpdate
(
test
.
replicaSet
,
10
,
20
)
if
result
!=
test
.
expected
{
t
.
Errorf
(
"case[%d]:%s Expected %v, Got: %v"
,
i
,
test
.
name
,
test
.
expected
,
result
)
}
})
}
}
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