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
14510866
Commit
14510866
authored
Oct 11, 2017
by
Brad Bowman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cmd tests to use ReleaseMock and assocaites from the helm package
parent
e974ab31
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
78 additions
and
139 deletions
+78
-139
delete_test.go
cmd/helm/delete_test.go
+9
-4
get_hooks_test.go
cmd/helm/get_hooks_test.go
+4
-2
get_manifest_test.go
cmd/helm/get_manifest_test.go
+4
-2
get_test.go
cmd/helm/get_test.go
+4
-2
get_values_test.go
cmd/helm/get_values_test.go
+3
-1
helm_test.go
cmd/helm/helm_test.go
+5
-87
history_test.go
cmd/helm/history_test.go
+4
-4
list_test.go
cmd/helm/list_test.go
+18
-18
reset_test.go
cmd/helm/reset_test.go
+2
-2
status_test.go
cmd/helm/status_test.go
+5
-5
upgrade_test.go
cmd/helm/upgrade_test.go
+20
-12
No files found.
cmd/helm/delete_test.go
View file @
14510866
...
...
@@ -23,6 +23,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestDelete
(
t
*
testing
.
T
)
{
...
...
@@ -33,28 +34,32 @@ func TestDelete(t *testing.T) {
args
:
[]
string
{
"aeneas"
},
flags
:
[]
string
{},
expected
:
""
,
// Output of a delete is an empty string and exit 0.
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"aeneas"
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
}),
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
})},
},
{
name
:
"delete with timeout"
,
args
:
[]
string
{
"aeneas"
},
flags
:
[]
string
{
"--timeout"
,
"120"
},
expected
:
""
,
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"aeneas"
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
}),
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
})},
},
{
name
:
"delete without hooks"
,
args
:
[]
string
{
"aeneas"
},
flags
:
[]
string
{
"--no-hooks"
},
expected
:
""
,
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"aeneas"
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
}),
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
})},
},
{
name
:
"purge"
,
args
:
[]
string
{
"aeneas"
},
flags
:
[]
string
{
"--purge"
},
expected
:
""
,
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"aeneas"
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
}),
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
})},
},
{
name
:
"delete without release"
,
...
...
cmd/helm/get_hooks_test.go
View file @
14510866
...
...
@@ -23,6 +23,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestGetHooks
(
t
*
testing
.
T
)
{
...
...
@@ -30,8 +31,9 @@ func TestGetHooks(t *testing.T) {
{
name
:
"get hooks with release"
,
args
:
[]
string
{
"aeneas"
},
expected
:
mockHookTemplate
,
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"aeneas"
}),
expected
:
helm
.
MockHookTemplate
,
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
}),
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"aeneas"
})},
},
{
name
:
"get hooks without args"
,
...
...
cmd/helm/get_manifest_test.go
View file @
14510866
...
...
@@ -23,6 +23,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestGetManifest
(
t
*
testing
.
T
)
{
...
...
@@ -30,8 +31,9 @@ func TestGetManifest(t *testing.T) {
{
name
:
"get manifest with release"
,
args
:
[]
string
{
"juno"
},
expected
:
mockManifest
,
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"juno"
}),
expected
:
helm
.
MockManifest
,
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"juno"
}),
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"juno"
})},
},
{
name
:
"get manifest without args"
,
...
...
cmd/helm/get_test.go
View file @
14510866
...
...
@@ -23,15 +23,17 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestGetCmd
(
t
*
testing
.
T
)
{
tests
:=
[]
releaseCase
{
{
name
:
"get with a release"
,
resp
:
releaseMock
(
&
releaseOptions
{
n
ame
:
"thomas-guide"
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
N
ame
:
"thomas-guide"
}),
args
:
[]
string
{
"thomas-guide"
},
expected
:
"REVISION: 1
\n
RELEASED: (.*)
\n
CHART: foo-0.1.0-beta.1
\n
USER-SUPPLIED VALUES:
\n
name:
\"
value
\"\n
COMPUTED VALUES:
\n
name: value
\n\n
HOOKS:
\n
---
\n
# pre-install-hook
\n
"
+
mockHookTemplate
+
"
\n
MANIFEST:"
,
expected
:
"REVISION: 1
\n
RELEASED: (.*)
\n
CHART: foo-0.1.0-beta.1
\n
USER-SUPPLIED VALUES:
\n
name:
\"
value
\"\n
COMPUTED VALUES:
\n
name: value
\n\n
HOOKS:
\n
---
\n
# pre-install-hook
\n
"
+
helm
.
MockHookTemplate
+
"
\n
MANIFEST:"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
})},
},
{
name
:
"get requires release name arg"
,
...
...
cmd/helm/get_values_test.go
View file @
14510866
...
...
@@ -23,15 +23,17 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestGetValuesCmd
(
t
*
testing
.
T
)
{
tests
:=
[]
releaseCase
{
{
name
:
"get values with a release"
,
resp
:
releaseMock
(
&
releaseOptions
{
n
ame
:
"thomas-guide"
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
N
ame
:
"thomas-guide"
}),
args
:
[]
string
{
"thomas-guide"
},
expected
:
"name:
\"
value
\"
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
})},
},
{
name
:
"get values requires release name arg"
,
...
...
cmd/helm/helm_test.go
View file @
14510866
...
...
@@ -21,115 +21,30 @@ import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"regexp"
"strings"
"testing"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/repo"
)
var
mockHookTemplate
=
`apiVersion: v1
kind: Job
metadata:
annotations:
"helm.sh/hooks": pre-install
`
var
mockManifest
=
`apiVersion: v1
kind: Secret
metadata:
name: fixture
`
type
releaseOptions
struct
{
name
string
version
int32
chart
*
chart
.
Chart
statusCode
release
.
Status_Code
namespace
string
}
func
releaseMock
(
opts
*
releaseOptions
)
*
release
.
Release
{
date
:=
timestamp
.
Timestamp
{
Seconds
:
242085845
,
Nanos
:
0
}
name
:=
opts
.
name
if
name
==
""
{
name
=
"testrelease-"
+
string
(
rand
.
Intn
(
100
))
}
var
version
int32
=
1
if
opts
.
version
!=
0
{
version
=
opts
.
version
}
namespace
:=
opts
.
namespace
if
namespace
==
""
{
namespace
=
"default"
}
ch
:=
opts
.
chart
if
opts
.
chart
==
nil
{
ch
=
&
chart
.
Chart
{
Metadata
:
&
chart
.
Metadata
{
Name
:
"foo"
,
Version
:
"0.1.0-beta.1"
,
},
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"templates/foo.tpl"
,
Data
:
[]
byte
(
mockManifest
)},
},
}
}
scode
:=
release
.
Status_DEPLOYED
if
opts
.
statusCode
>
0
{
scode
=
opts
.
statusCode
}
return
&
release
.
Release
{
Name
:
name
,
Info
:
&
release
.
Info
{
FirstDeployed
:
&
date
,
LastDeployed
:
&
date
,
Status
:
&
release
.
Status
{
Code
:
scode
},
Description
:
"Release mock"
,
},
Chart
:
ch
,
Config
:
&
chart
.
Config
{
Raw
:
`name: "value"`
},
Version
:
version
,
Namespace
:
namespace
,
Hooks
:
[]
*
release
.
Hook
{
{
Name
:
"pre-install-hook"
,
Kind
:
"Job"
,
Path
:
"pre-install-hook.yaml"
,
Manifest
:
mockHookTemplate
,
LastRun
:
&
date
,
Events
:
[]
release
.
Hook_Event
{
release
.
Hook_PRE_INSTALL
},
},
},
Manifest
:
mockManifest
,
}
}
// releaseCmd is a command that works with a FakeClient
type
releaseCmd
func
(
c
*
helm
.
FakeClient
,
out
io
.
Writer
)
*
cobra
.
Command
// runReleaseCases runs a set of release cases through the given releaseCmd.
func
runReleaseCases
(
t
*
testing
.
T
,
tests
[]
releaseCase
,
rcmd
releaseCmd
)
{
var
buf
bytes
.
Buffer
for
_
,
tt
:=
range
tests
{
c
:=
&
helm
.
FakeClient
{
Rels
:
[]
*
release
.
Release
{
tt
.
resp
}
,
Rels
:
tt
.
rels
,
}
cmd
:=
rcmd
(
c
,
&
buf
)
cmd
.
ParseFlags
(
tt
.
flags
)
...
...
@@ -154,6 +69,8 @@ type releaseCase struct {
expected
string
err
bool
resp
*
release
.
Release
// Rels are the available releases at the start of the test.
rels
[]
*
release
.
Release
}
// tempHelmHome sets up a Helm Home in a temp dir.
...
...
@@ -230,6 +147,7 @@ func ensureTestHome(home helmpath.Home, t *testing.T) error {
t
.
Logf
(
"$HELM_HOME has been configured at %s.
\n
"
,
settings
.
Home
.
String
())
return
nil
}
func
TestRootCmd
(
t
*
testing
.
T
)
{
...
...
cmd/helm/history_test.go
View file @
14510866
...
...
@@ -27,10 +27,10 @@ import (
func
TestHistoryCmd
(
t
*
testing
.
T
)
{
mk
:=
func
(
name
string
,
vers
int32
,
code
rpb
.
Status_Code
)
*
rpb
.
Release
{
return
releaseMock
(
&
r
eleaseOptions
{
n
ame
:
name
,
v
ersion
:
vers
,
s
tatusCode
:
code
,
return
helm
.
ReleaseMock
(
&
helm
.
MockR
eleaseOptions
{
N
ame
:
name
,
V
ersion
:
vers
,
S
tatusCode
:
code
,
})
}
...
...
cmd/helm/list_test.go
View file @
14510866
...
...
@@ -36,7 +36,7 @@ func TestListCmd(t *testing.T) {
{
name
:
"with a release"
,
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
n
ame
:
"thomas-guide"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
N
ame
:
"thomas-guide"
}),
},
expected
:
"thomas-guide"
,
},
...
...
@@ -44,7 +44,7 @@ func TestListCmd(t *testing.T) {
name
:
"list"
,
args
:
[]
string
{},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
n
ame
:
"atlas"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
N
ame
:
"atlas"
}),
},
expected
:
"NAME
\t
REVISION
\t
UPDATED
\t
STATUS
\t
CHART
\t
NAMESPACE
\n
atlas
\t
1
\t
(.*)
\t
DEPLOYED
\t
foo-0.1.0-beta.1
\t
default
\n
"
,
},
...
...
@@ -52,8 +52,8 @@ func TestListCmd(t *testing.T) {
name
:
"list, one deployed, one failed"
,
args
:
[]
string
{
"-q"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
s
tatusCode
:
release
.
Status_FAILED
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
S
tatusCode
:
release
.
Status_FAILED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
},
expected
:
"thomas-guide
\n
atlas-guide"
,
},
...
...
@@ -61,8 +61,8 @@ func TestListCmd(t *testing.T) {
name
:
"with a release, multiple flags"
,
args
:
[]
string
{
"--deleted"
,
"--deployed"
,
"--failed"
,
"-q"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
s
tatusCode
:
release
.
Status_DELETED
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
S
tatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
},
// Note: We're really only testing that the flags parsed correctly. Which results are returned
// depends on the backend. And until pkg/helm is done, we can't mock this.
...
...
@@ -72,8 +72,8 @@ func TestListCmd(t *testing.T) {
name
:
"with a release, multiple flags"
,
args
:
[]
string
{
"--all"
,
"-q"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
s
tatusCode
:
release
.
Status_DELETED
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
S
tatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
},
// See note on previous test.
expected
:
"thomas-guide
\n
atlas-guide"
,
...
...
@@ -82,8 +82,8 @@ func TestListCmd(t *testing.T) {
name
:
"with a release, multiple flags, deleting"
,
args
:
[]
string
{
"--all"
,
"-q"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
s
tatusCode
:
release
.
Status_DELETING
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
S
tatusCode
:
release
.
Status_DELETING
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
},
// See note on previous test.
expected
:
"thomas-guide
\n
atlas-guide"
,
...
...
@@ -92,8 +92,8 @@ func TestListCmd(t *testing.T) {
name
:
"namespace defined, multiple flags"
,
args
:
[]
string
{
"--all"
,
"-q"
,
"--namespace test123"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
n
amespace
:
"test123"
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
n
amespace
:
"test321"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
N
amespace
:
"test123"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
N
amespace
:
"test321"
}),
},
// See note on previous test.
expected
:
"thomas-guide"
,
...
...
@@ -102,8 +102,8 @@ func TestListCmd(t *testing.T) {
name
:
"with a pending release, multiple flags"
,
args
:
[]
string
{
"--all"
,
"-q"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
s
tatusCode
:
release
.
Status_PENDING_INSTALL
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
S
tatusCode
:
release
.
Status_PENDING_INSTALL
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
},
expected
:
"thomas-guide
\n
atlas-guide"
,
},
...
...
@@ -111,10 +111,10 @@ func TestListCmd(t *testing.T) {
name
:
"with a pending release, pending flag"
,
args
:
[]
string
{
"--pending"
,
"-q"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
s
tatusCode
:
release
.
Status_PENDING_INSTALL
}),
releaseMock
(
&
releaseOptions
{
name
:
"wild-idea"
,
s
tatusCode
:
release
.
Status_PENDING_UPGRADE
}),
releaseMock
(
&
releaseOptions
{
name
:
"crazy-maps"
,
s
tatusCode
:
release
.
Status_PENDING_ROLLBACK
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
S
tatusCode
:
release
.
Status_PENDING_INSTALL
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"wild-idea"
,
S
tatusCode
:
release
.
Status_PENDING_UPGRADE
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-maps"
,
S
tatusCode
:
release
.
Status_PENDING_ROLLBACK
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
},
expected
:
"thomas-guide
\n
wild-idea
\n
crazy-maps"
,
},
...
...
cmd/helm/reset_test.go
View file @
14510866
...
...
@@ -107,7 +107,7 @@ func TestReset_deployedReleases(t *testing.T) {
var
buf
bytes
.
Buffer
resp
:=
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
}
c
:=
&
helm
.
FakeClient
{
Rels
:
resp
,
...
...
@@ -139,7 +139,7 @@ func TestReset_forceFlag(t *testing.T) {
var
buf
bytes
.
Buffer
resp
:=
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
s
tatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
S
tatusCode
:
release
.
Status_DEPLOYED
}),
}
c
:=
&
helm
.
FakeClient
{
Rels
:
resp
,
...
...
cmd/helm/status_test.go
View file @
14510866
...
...
@@ -52,7 +52,7 @@ func TestStatusCmd(t *testing.T) {
name
:
"get status of a deployed release"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
expected
:
outputWithStatus
(
"DEPLOYED
\n\n
"
),
rel
:
r
eleaseMockWithStatus
(
&
release
.
Status
{
rel
:
R
eleaseMockWithStatus
(
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
,
}),
},
...
...
@@ -60,7 +60,7 @@ func TestStatusCmd(t *testing.T) {
name
:
"get status of a deployed release with notes"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
expected
:
outputWithStatus
(
"DEPLOYED
\n\n
NOTES:
\n
release notes
\n
"
),
rel
:
r
eleaseMockWithStatus
(
&
release
.
Status
{
rel
:
R
eleaseMockWithStatus
(
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
,
Notes
:
"release notes"
,
}),
...
...
@@ -69,7 +69,7 @@ func TestStatusCmd(t *testing.T) {
name
:
"get status of a deployed release with resources"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
expected
:
outputWithStatus
(
"DEPLOYED
\n\n
RESOURCES:
\n
resource A
\n
resource B
\n\n
"
),
rel
:
r
eleaseMockWithStatus
(
&
release
.
Status
{
rel
:
R
eleaseMockWithStatus
(
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
,
Resources
:
"resource A
\n
resource B
\n
"
,
}),
...
...
@@ -82,7 +82,7 @@ func TestStatusCmd(t *testing.T) {
"TEST
\t
STATUS
\t
INFO
\t
STARTED
\t
COMPLETED
\n
"
+
fmt
.
Sprintf
(
"test run 1
\t
SUCCESS
\t
extra info
\t
%s
\t
%s
\n
"
,
dateString
,
dateString
)
+
fmt
.
Sprintf
(
"test run 2
\t
FAILURE
\t
\t
%s
\t
%s
\n
"
,
dateString
,
dateString
)),
rel
:
r
eleaseMockWithStatus
(
&
release
.
Status
{
rel
:
R
eleaseMockWithStatus
(
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
,
LastTestSuiteRun
:
&
release
.
TestSuite
{
StartedAt
:
&
date
,
...
...
@@ -138,7 +138,7 @@ func outputWithStatus(status string) string {
status
)
}
func
r
eleaseMockWithStatus
(
status
*
release
.
Status
)
*
release
.
Release
{
func
R
eleaseMockWithStatus
(
status
*
release
.
Status
)
*
release
.
Release
{
return
&
release
.
Release
{
Name
:
"flummoxed-chickadee"
,
Info
:
&
release
.
Info
{
...
...
cmd/helm/upgrade_test.go
View file @
14510866
...
...
@@ -28,6 +28,7 @@ import (
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestUpgradeCmd
(
t
*
testing
.
T
)
{
...
...
@@ -43,9 +44,9 @@ func TestUpgradeCmd(t *testing.T) {
t
.
Errorf
(
"Error creating chart for upgrade: %v"
,
err
)
}
ch
,
_
:=
chartutil
.
Load
(
chartPath
)
_
=
releaseMock
(
&
r
eleaseOptions
{
n
ame
:
"funny-bunny"
,
c
hart
:
ch
,
_
=
helm
.
ReleaseMock
(
&
helm
.
MockR
eleaseOptions
{
N
ame
:
"funny-bunny"
,
C
hart
:
ch
,
})
// update chart version
...
...
@@ -94,61 +95,68 @@ func TestUpgradeCmd(t *testing.T) {
{
name
:
"upgrade a release"
,
args
:
[]
string
{
"funny-bunny"
,
chartPath
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"funny-bunny"
,
version
:
2
,
c
hart
:
ch
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
2
,
C
hart
:
ch
}),
expected
:
"Release
\"
funny-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
2
,
Chart
:
ch
})},
},
{
name
:
"upgrade a release with timeout"
,
args
:
[]
string
{
"funny-bunny"
,
chartPath
},
flags
:
[]
string
{
"--timeout"
,
"120"
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"funny-bunny"
,
version
:
3
,
c
hart
:
ch2
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
3
,
C
hart
:
ch2
}),
expected
:
"Release
\"
funny-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
3
,
Chart
:
ch2
})},
},
{
name
:
"upgrade a release with --reset-values"
,
args
:
[]
string
{
"funny-bunny"
,
chartPath
},
flags
:
[]
string
{
"--reset-values"
,
"true"
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"funny-bunny"
,
version
:
4
,
c
hart
:
ch2
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
4
,
C
hart
:
ch2
}),
expected
:
"Release
\"
funny-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
4
,
Chart
:
ch2
})},
},
{
name
:
"upgrade a release with --reuse-values"
,
args
:
[]
string
{
"funny-bunny"
,
chartPath
},
flags
:
[]
string
{
"--reuse-values"
,
"true"
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"funny-bunny"
,
version
:
5
,
c
hart
:
ch2
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
5
,
C
hart
:
ch2
}),
expected
:
"Release
\"
funny-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"funny-bunny"
,
Version
:
5
,
Chart
:
ch2
})},
},
{
name
:
"install a release with 'upgrade --install'"
,
args
:
[]
string
{
"zany-bunny"
,
chartPath
},
flags
:
[]
string
{
"-i"
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"zany-bunny"
,
version
:
1
,
c
hart
:
ch
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"zany-bunny"
,
Version
:
1
,
C
hart
:
ch
}),
expected
:
"Release
\"
zany-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"zany-bunny"
,
Version
:
1
,
Chart
:
ch
})},
},
{
name
:
"install a release with 'upgrade --install' and timeout"
,
args
:
[]
string
{
"crazy-bunny"
,
chartPath
},
flags
:
[]
string
{
"-i"
,
"--timeout"
,
"120"
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"crazy-bunny"
,
version
:
1
,
c
hart
:
ch
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-bunny"
,
Version
:
1
,
C
hart
:
ch
}),
expected
:
"Release
\"
crazy-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-bunny"
,
Version
:
1
,
Chart
:
ch
})},
},
{
name
:
"upgrade a release with wait"
,
args
:
[]
string
{
"crazy-bunny"
,
chartPath
},
flags
:
[]
string
{
"--wait"
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"crazy-bunny"
,
version
:
2
,
c
hart
:
ch2
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-bunny"
,
Version
:
2
,
C
hart
:
ch2
}),
expected
:
"Release
\"
crazy-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-bunny"
,
Version
:
2
,
Chart
:
ch2
})},
},
{
name
:
"upgrade a release with missing dependencies"
,
args
:
[]
string
{
"bonkers-bunny"
,
missingDepsPath
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"bonkers-bunny"
,
version
:
1
,
c
hart
:
ch3
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"bonkers-bunny"
,
Version
:
1
,
C
hart
:
ch3
}),
err
:
true
,
},
{
name
:
"upgrade a release with bad dependencies"
,
args
:
[]
string
{
"bonkers-bunny"
,
badDepsPath
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"bonkers-bunny"
,
version
:
1
,
c
hart
:
ch3
}),
resp
:
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"bonkers-bunny"
,
Version
:
1
,
C
hart
:
ch3
}),
err
:
true
,
},
}
...
...
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