Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
68e1d820
Commit
68e1d820
authored
Mar 31, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #530 from technosophos/fix/test-manager-put-dep
fix(manager): add test for put deployment.
parents
b93cb085
a6b9b8c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
deployments_test.go
cmd/manager/deployments_test.go
+42
-0
testutil.go
cmd/manager/testutil.go
+7
-1
No files found.
cmd/manager/deployments_test.go
View file @
68e1d820
...
@@ -171,3 +171,45 @@ func TestDeleteDeployments(t *testing.T) {
...
@@ -171,3 +171,45 @@ func TestDeleteDeployments(t *testing.T) {
t
.
Errorf
(
"Unexpected name %q"
,
out
.
Name
)
t
.
Errorf
(
"Unexpected name %q"
,
out
.
Name
)
}
}
}
}
func
TestPutDeployment
(
t
*
testing
.
T
)
{
c
:=
stubContext
()
s
:=
httpHarness
(
c
,
"PUT /deployments/*"
,
putDeploymentHandlerFunc
)
defer
s
.
Close
()
man
:=
c
.
Manager
.
(
*
mockManager
)
man
.
deployments
=
[]
*
common
.
Deployment
{
{
Name
:
"demeter"
,
State
:
&
common
.
DeploymentState
{
Status
:
common
.
CreatedStatus
}},
}
depreq
:=
&
common
.
DeploymentRequest
{
Name
:
"demeter"
}
depreq
.
Configuration
=
common
.
Configuration
{
Resources
:
[]
*
common
.
Resource
{}}
out
,
err
:=
json
.
Marshal
(
depreq
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to marshal DeploymentRequest: %s"
,
err
)
}
req
,
err
:=
http
.
NewRequest
(
"PUT"
,
s
.
URL
+
"/deployments/demeter"
,
bytes
.
NewBuffer
(
out
))
if
err
!=
nil
{
t
.
Fatal
(
"Failed to create PUT request"
)
}
res
,
err
:=
http
.
DefaultClient
.
Do
(
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to execute PUT request: %s"
,
err
)
}
if
res
.
StatusCode
!=
201
{
t
.
Errorf
(
"Expected status code 201, got %d"
,
res
.
StatusCode
)
}
d
:=
&
common
.
Deployment
{}
if
err
:=
json
.
NewDecoder
(
res
.
Body
)
.
Decode
(
&
d
);
err
!=
nil
{
t
.
Errorf
(
"Failed to parse results: %s"
,
err
)
return
}
if
d
.
Name
!=
"demeter"
{
t
.
Errorf
(
"Unexpected name %q"
,
d
.
Name
)
}
}
cmd/manager/testutil.go
View file @
68e1d820
...
@@ -99,7 +99,13 @@ func (m *mockManager) DeleteDeployment(name string, forget bool) (*common.Deploy
...
@@ -99,7 +99,13 @@ func (m *mockManager) DeleteDeployment(name string, forget bool) (*common.Deploy
}
}
func
(
m
*
mockManager
)
PutDeployment
(
name
string
,
depReq
*
common
.
DeploymentRequest
)
(
*
common
.
Deployment
,
error
)
{
func
(
m
*
mockManager
)
PutDeployment
(
name
string
,
depReq
*
common
.
DeploymentRequest
)
(
*
common
.
Deployment
,
error
)
{
return
&
common
.
Deployment
{},
nil
for
_
,
d
:=
range
m
.
deployments
{
if
d
.
Name
==
name
{
d
.
State
.
Status
=
common
.
ModifiedStatus
return
d
,
nil
}
}
return
nil
,
errors
.
New
(
"Deployment not found"
)
}
}
func
(
m
*
mockManager
)
ListManifests
(
deploymentName
string
)
(
map
[
string
]
*
common
.
Manifest
,
error
)
{
func
(
m
*
mockManager
)
ListManifests
(
deploymentName
string
)
(
map
[
string
]
*
common
.
Manifest
,
error
)
{
...
...
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