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
3539586c
Commit
3539586c
authored
Mar 29, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #490 from technosophos/fix/manager-test-delete-deployment
fix(manager): add test for delete deployment API
parents
61a9296b
efeac792
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
deployments_test.go
cmd/manager/deployments_test.go
+35
-0
testutil.go
cmd/manager/testutil.go
+8
-1
No files found.
cmd/manager/deployments_test.go
View file @
3539586c
...
...
@@ -136,3 +136,38 @@ func TestGetDeployments(t *testing.T) {
t
.
Errorf
(
"Unexpected status %d"
,
out
.
State
.
Status
)
}
}
func
TestDeleteDeployments
(
t
*
testing
.
T
)
{
c
:=
stubContext
()
s
:=
httpHarness
(
c
,
"DELETE /deployments/*"
,
deleteDeploymentHandlerFunc
)
defer
s
.
Close
()
man
:=
c
.
Manager
.
(
*
mockManager
)
man
.
deployments
=
[]
*
common
.
Deployment
{
{
Name
:
"portunes"
,
State
:
&
common
.
DeploymentState
{
Status
:
common
.
CreatedStatus
}},
}
req
,
err
:=
http
.
NewRequest
(
"DELETE"
,
s
.
URL
+
"/deployments/portunes"
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
"Failed to create delete request"
)
}
res
,
err
:=
http
.
DefaultClient
.
Do
(
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to execute delete request: %s"
,
err
)
}
if
res
.
StatusCode
!=
200
{
t
.
Errorf
(
"Expected status code 200, got %d"
,
res
.
StatusCode
)
}
var
out
common
.
Deployment
if
err
:=
json
.
NewDecoder
(
res
.
Body
)
.
Decode
(
&
out
);
err
!=
nil
{
t
.
Errorf
(
"Failed to parse results: %s"
,
err
)
return
}
if
out
.
Name
!=
"portunes"
{
t
.
Errorf
(
"Unexpected name %q"
,
out
.
Name
)
}
}
cmd/manager/testutil.go
View file @
3539586c
...
...
@@ -18,6 +18,7 @@ package main
import
(
"errors"
"fmt"
"net/http/httptest"
"regexp"
...
...
@@ -88,7 +89,13 @@ func (m *mockManager) CreateDeployment(depReq *common.DeploymentRequest) (*commo
}
func
(
m
*
mockManager
)
DeleteDeployment
(
name
string
,
forget
bool
)
(
*
common
.
Deployment
,
error
)
{
return
&
common
.
Deployment
{},
nil
for
_
,
d
:=
range
m
.
deployments
{
if
d
.
Name
==
name
{
return
d
,
nil
}
}
fmt
.
Printf
(
"Could not find %s"
,
name
)
return
nil
,
errors
.
New
(
"Deployment not found"
)
}
func
(
m
*
mockManager
)
PutDeployment
(
name
string
,
depReq
*
common
.
DeploymentRequest
)
(
*
common
.
Deployment
,
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