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
e988ca1a
Commit
e988ca1a
authored
Mar 18, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #407 from technosophos/fix/manager-stub
fix(manager): add stub for context with Manager
parents
131ddcbc
9473ddff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
4 deletions
+90
-4
deployments_test.go
cmd/manager/deployments_test.go
+90
-4
No files found.
cmd/manager/deployments_test.go
View file @
e988ca1a
...
...
@@ -3,13 +3,18 @@ package main
import
(
"net/http"
"net/http/httptest"
"net/url"
"regexp"
"testing"
"github.com/kubernetes/helm/cmd/manager/router"
"github.com/kubernetes/helm/pkg/common"
"github.com/kubernetes/helm/pkg/httputil"
"github.com/kubernetes/helm/pkg/registry"
)
func
TestHealthz
(
t
*
testing
.
T
)
{
c
:=
mock
Context
()
c
:=
stub
Context
()
s
:=
httpHarness
(
c
,
"GET /"
,
healthz
)
defer
s
.
Close
()
...
...
@@ -33,7 +38,88 @@ func httpHarness(c *router.Context, route string, fn router.HandlerFunc) *httpte
return
httptest
.
NewServer
(
h
)
}
func
mockContext
()
*
router
.
Context
{
// TODO: We need mocks for credentials and manager.
return
&
router
.
Context
{}
// stubContext creates a stub of a Context object.
//
// This creates a stub context with the following properties:
// - Config is initialized to empty values
// - Encoder is initialized to httputil.DefaultEncoder
// - CredentialProvider is initialized to registry.InmemCredentialProvider
// - Manager is initialized to mockManager.
func
stubContext
()
*
router
.
Context
{
return
&
router
.
Context
{
Config
:
&
router
.
Config
{},
Manager
:
&
mockManager
{},
CredentialProvider
:
registry
.
NewInmemCredentialProvider
(),
Encoder
:
httputil
.
DefaultEncoder
,
}
}
type
mockManager
struct
{}
func
(
m
*
mockManager
)
ListDeployments
()
([]
common
.
Deployment
,
error
)
{
return
[]
common
.
Deployment
{},
nil
}
func
(
m
*
mockManager
)
GetDeployment
(
name
string
)
(
*
common
.
Deployment
,
error
)
{
return
&
common
.
Deployment
{},
nil
}
func
(
m
*
mockManager
)
CreateDeployment
(
t
*
common
.
Template
)
(
*
common
.
Deployment
,
error
)
{
return
&
common
.
Deployment
{},
nil
}
func
(
m
*
mockManager
)
DeleteDeployment
(
name
string
,
forget
bool
)
(
*
common
.
Deployment
,
error
)
{
return
&
common
.
Deployment
{},
nil
}
func
(
m
*
mockManager
)
PutDeployment
(
name
string
,
t
*
common
.
Template
)
(
*
common
.
Deployment
,
error
)
{
return
&
common
.
Deployment
{},
nil
}
func
(
m
*
mockManager
)
ListManifests
(
deploymentName
string
)
(
map
[
string
]
*
common
.
Manifest
,
error
)
{
return
map
[
string
]
*
common
.
Manifest
{},
nil
}
func
(
m
*
mockManager
)
GetManifest
(
deploymentName
string
,
manifest
string
)
(
*
common
.
Manifest
,
error
)
{
return
&
common
.
Manifest
{},
nil
}
func
(
m
*
mockManager
)
Expand
(
t
*
common
.
Template
)
(
*
common
.
Manifest
,
error
)
{
return
&
common
.
Manifest
{},
nil
}
func
(
m
*
mockManager
)
ListTypes
()
([]
string
,
error
)
{
return
[]
string
{},
nil
}
func
(
m
*
mockManager
)
ListInstances
(
typeName
string
)
([]
*
common
.
TypeInstance
,
error
)
{
return
[]
*
common
.
TypeInstance
{},
nil
}
func
(
m
*
mockManager
)
GetRegistryForType
(
typeName
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
m
*
mockManager
)
GetMetadataForType
(
typeName
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
m
*
mockManager
)
ListRegistries
()
([]
*
common
.
Registry
,
error
)
{
return
[]
*
common
.
Registry
{},
nil
}
func
(
m
*
mockManager
)
CreateRegistry
(
pr
*
common
.
Registry
)
error
{
return
nil
}
func
(
m
*
mockManager
)
GetRegistry
(
name
string
)
(
*
common
.
Registry
,
error
)
{
return
&
common
.
Registry
{},
nil
}
func
(
m
*
mockManager
)
DeleteRegistry
(
name
string
)
error
{
return
nil
}
func
(
m
*
mockManager
)
ListRegistryTypes
(
registryName
string
,
regex
*
regexp
.
Regexp
)
([]
registry
.
Type
,
error
)
{
return
[]
registry
.
Type
{},
nil
}
func
(
m
*
mockManager
)
GetDownloadURLs
(
registryName
string
,
t
registry
.
Type
)
([]
*
url
.
URL
,
error
)
{
return
[]
*
url
.
URL
{},
nil
}
func
(
m
*
mockManager
)
GetFile
(
registryName
string
,
url
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
m
*
mockManager
)
CreateCredential
(
name
string
,
c
*
common
.
RegistryCredential
)
error
{
return
nil
}
func
(
m
*
mockManager
)
GetCredential
(
name
string
)
(
*
common
.
RegistryCredential
,
error
)
{
return
&
common
.
RegistryCredential
{},
nil
}
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