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
a5ef8a22
Commit
a5ef8a22
authored
Apr 12, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from technosophos/feat/env-tests
fix(environment): add tests for Environment
parents
54552182
b86a1cb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
2 deletions
+68
-2
environment_test.go
cmd/tiller/environment/environment_test.go
+50
-0
server.go
cmd/tiller/server.go
+18
-2
No files found.
cmd/tiller/environment/environment_test.go
View file @
a5ef8a22
...
...
@@ -14,7 +14,29 @@ func (e *mockEngine) Render(chrt *hapi.Chart, v *hapi.Values) ([]byte, error) {
return
e
.
out
,
nil
}
type
mockReleaseStorage
struct
{
rel
*
hapi
.
Release
}
func
(
r
*
mockReleaseStorage
)
Get
(
k
string
)
(
*
hapi
.
Release
,
error
)
{
return
r
.
rel
,
nil
}
func
(
r
*
mockReleaseStorage
)
Set
(
k
string
,
v
*
hapi
.
Release
)
error
{
r
.
rel
=
v
return
nil
}
type
mockKubeClient
struct
{
}
func
(
k
*
mockKubeClient
)
Install
(
manifest
[]
byte
)
error
{
return
nil
}
var
_
Engine
=
&
mockEngine
{}
var
_
ReleaseStorage
=
&
mockReleaseStorage
{}
var
_
KubeClient
=
&
mockKubeClient
{}
func
TestEngine
(
t
*
testing
.
T
)
{
eng
:=
&
mockEngine
{
out
:
[]
byte
(
"test"
)}
...
...
@@ -30,3 +52,31 @@ func TestEngine(t *testing.T) {
t
.
Errorf
(
"expected 'test', got %q"
,
string
(
out
))
}
}
func
TestReleaseStorage
(
t
*
testing
.
T
)
{
rs
:=
&
mockReleaseStorage
{}
env
:=
New
()
env
.
Releases
=
rs
release
:=
&
hapi
.
Release
{
Name
:
"mariner"
}
if
err
:=
env
.
Releases
.
Set
(
"albatross"
,
release
);
err
!=
nil
{
t
.
Fatalf
(
"failed to store release: %s"
,
err
)
}
if
v
,
err
:=
env
.
Releases
.
Get
(
"albatross"
);
err
!=
nil
{
t
.
Errorf
(
"Error fetching release: %s"
,
err
)
}
else
if
v
.
Name
!=
"mariner"
{
t
.
Errorf
(
"Expected mariner, got %q"
,
v
.
Name
)
}
}
func
TestKubeClient
(
t
*
testing
.
T
)
{
kc
:=
&
mockKubeClient
{}
env
:=
New
()
env
.
KubeClient
=
kc
if
err
:=
env
.
KubeClient
.
Install
([]
byte
(
"apiVersion: v1
\n
"
));
err
!=
nil
{
t
.
Errorf
(
"Kubeclient failed: %s"
,
err
)
}
}
cmd/tiller/server.go
View file @
a5ef8a22
...
...
@@ -3,24 +3,40 @@ package main
import
(
"net"
"github.com/deis/tiller/cmd/tiller/environment"
"github.com/deis/tiller/pkg/hapi"
ctx
"golang.org/x/net/context"
"google.golang.org/grpc"
)
type
server
struct
{}
type
server
struct
{
Environment
*
environment
.
Environment
}
// newServer creates a new server with the default environment.
//
// TODO: This can take a configuration object of some sort so that we can
// initialize the environment with the correct stuff.
func
newServer
()
*
server
{
return
&
server
{
Environment
:
environment
.
New
(),
}
}
func
(
s
*
server
)
Ready
(
c
ctx
.
Context
,
req
*
hapi
.
PingRequest
)
(
*
hapi
.
PingResponse
,
error
)
{
return
&
hapi
.
PingResponse
{
Status
:
"OK"
},
nil
}
// startServer starts a new gRPC server listening on the given address.
//
// addr must conform to the requirements of "net.Listen".
func
startServer
(
addr
string
)
error
{
lstn
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
return
nil
}
hserver
:=
&
server
{}
hserver
:=
newServer
()
srv
:=
grpc
.
NewServer
()
hapi
.
RegisterProbeServer
(
srv
,
hserver
)
...
...
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