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
94b3c216
Commit
94b3c216
authored
Mar 06, 2017
by
Anthony Yeh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deployment: Consolidate Adopt/Release unit tests.
parent
f2a2895a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
38 deletions
+9
-38
deployment_controller_test.go
pkg/controller/deployment/deployment_controller_test.go
+9
-38
No files found.
pkg/controller/deployment/deployment_controller_test.go
View file @
94b3c216
...
...
@@ -420,50 +420,21 @@ func TestGetReplicaSetsForDeployment(t *testing.T) {
}
}
func
TestGetReplicaSetsForDeploymentAdopt
(
t
*
testing
.
T
)
{
func
TestGetReplicaSetsForDeploymentAdopt
Release
(
t
*
testing
.
T
)
{
f
:=
newFixture
(
t
)
d
:=
newDeployment
(
"foo"
,
1
,
nil
,
nil
,
nil
,
map
[
string
]
string
{
"foo"
:
"bar"
})
// RS with matching labels, but orphaned. Should be adopted and returned.
rs
:=
newReplicaSet
(
d
,
"rs"
,
1
)
rs
.
OwnerReferences
=
nil
f
.
dLister
=
append
(
f
.
dLister
,
d
)
f
.
rsLister
=
append
(
f
.
rsLister
,
rs
)
f
.
objects
=
append
(
f
.
objects
,
d
,
rs
)
// Start the fixture.
c
,
informers
:=
f
.
newController
()
stopCh
:=
make
(
chan
struct
{})
defer
close
(
stopCh
)
informers
.
Start
(
stopCh
)
rsList
,
err
:=
c
.
getReplicaSetsForDeployment
(
d
)
if
err
!=
nil
{
t
.
Fatalf
(
"getReplicaSetsForDeployment() error: %v"
,
err
)
}
rsNames
:=
[]
string
{}
for
_
,
rs
:=
range
rsList
{
rsNames
=
append
(
rsNames
,
rs
.
Name
)
}
if
len
(
rsNames
)
!=
1
||
rsNames
[
0
]
!=
rs
.
Name
{
t
.
Errorf
(
"getReplicaSetsForDeployment() = %v, want [%v]"
,
rsNames
,
rs
.
Name
)
}
}
func
TestGetReplicaSetsForDeploymentRelease
(
t
*
testing
.
T
)
{
f
:=
newFixture
(
t
)
d
:=
newDeployment
(
"foo"
,
1
,
nil
,
nil
,
nil
,
map
[
string
]
string
{
"foo"
:
"bar"
})
rsAdopt
:=
newReplicaSet
(
d
,
"rsAdopt"
,
1
)
rsAdopt
.
OwnerReferences
=
nil
// RS with matching ControllerRef, but wrong labels. Should be released.
rs
:=
newReplicaSet
(
d
,
"rs
"
,
1
)
rs
.
Labels
=
map
[
string
]
string
{
"foo"
:
"notbar"
}
rs
Release
:=
newReplicaSet
(
d
,
"rsRelease
"
,
1
)
rs
Release
.
Labels
=
map
[
string
]
string
{
"foo"
:
"notbar"
}
f
.
dLister
=
append
(
f
.
dLister
,
d
)
f
.
rsLister
=
append
(
f
.
rsLister
,
rs
)
f
.
objects
=
append
(
f
.
objects
,
d
,
rs
)
f
.
rsLister
=
append
(
f
.
rsLister
,
rs
Adopt
,
rsRelease
)
f
.
objects
=
append
(
f
.
objects
,
d
,
rs
Adopt
,
rsRelease
)
// Start the fixture.
c
,
informers
:=
f
.
newController
()
...
...
@@ -479,8 +450,8 @@ func TestGetReplicaSetsForDeploymentRelease(t *testing.T) {
for
_
,
rs
:=
range
rsList
{
rsNames
=
append
(
rsNames
,
rs
.
Name
)
}
if
len
(
rsNames
)
!=
0
{
t
.
Errorf
(
"getReplicaSetsForDeployment() = %v, want [
]"
,
rsNames
)
if
len
(
rsNames
)
!=
1
||
rsNames
[
0
]
!=
rsAdopt
.
Name
{
t
.
Errorf
(
"getReplicaSetsForDeployment() = %v, want [
%v]"
,
rsNames
,
rsAdopt
.
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