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
b9904281
Commit
b9904281
authored
Jun 28, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(cmd): add pattern for testing cmd package
parent
8cb39ce5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
0 deletions
+89
-0
list_test.go
cmd/helm/list_test.go
+89
-0
No files found.
cmd/helm/list_test.go
0 → 100644
View file @
b9904281
package
main
import
(
"bytes"
"testing"
"k8s.io/helm/pkg/helm"
)
// Stubbed out tests at two diffent layers
// TestList() is testing the command action
// TestListCmd() is testing command line interface
// TODO mock tiller responses
func
TestList
(
t
*
testing
.
T
)
{
helm
.
Config
.
ServAddr
=
":44134"
tests
:=
[]
struct
{
name
string
lister
*
lister
expected
string
err
bool
}{
{
name
:
"with a release"
,
lister
:
&
lister
{},
expected
:
"understood-coral"
,
},
{
name
:
"list --long"
,
lister
:
&
lister
{
long
:
true
},
expected
:
"NAME
\t
UPDATED
\t
STATUS
\t
CHART
\n
understood-coral
\t
Tue Jun 28 12:29:54 2016
\t
DEPLOYED
\t
nginx-0.1.0"
,
},
}
var
buf
bytes
.
Buffer
for
_
,
tt
:=
range
tests
{
tt
.
lister
.
out
=
&
buf
err
:=
tt
.
lister
.
run
([]
string
{})
if
(
err
!=
nil
)
!=
tt
.
err
{
t
.
Errorf
(
"%q. expected error: %v, got %v"
,
tt
.
name
,
tt
.
err
,
err
)
}
actual
:=
string
(
bytes
.
TrimSpace
(
buf
.
Bytes
()))
if
actual
!=
tt
.
expected
{
t
.
Errorf
(
"%q. expected %q, got %q"
,
tt
.
name
,
tt
.
expected
,
actual
)
}
buf
.
Reset
()
}
}
func
TestListCmd
(
t
*
testing
.
T
)
{
helm
.
Config
.
ServAddr
=
":44134"
tests
:=
[]
struct
{
name
string
args
[]
string
flags
map
[
string
]
string
expected
string
err
bool
}{
{
name
:
"with a release"
,
expected
:
"understood-coral"
,
},
{
name
:
"list --long"
,
flags
:
map
[
string
]
string
{
"long"
:
"1"
},
expected
:
"NAME
\t
UPDATED
\t
STATUS
\t
CHART
\n
understood-coral
\t
Tue Jun 28 12:29:54 2016
\t
DEPLOYED
\t
nginx-0.1.0"
,
},
}
var
buf
bytes
.
Buffer
for
_
,
tt
:=
range
tests
{
cmd
:=
newListCmd
(
&
buf
)
for
flag
,
value
:=
range
tt
.
flags
{
cmd
.
Flags
()
.
Set
(
flag
,
value
)
}
err
:=
cmd
.
RunE
(
cmd
,
tt
.
args
)
if
(
err
!=
nil
)
!=
tt
.
err
{
t
.
Errorf
(
"%q. expected error: %v, got %v"
,
tt
.
name
,
tt
.
err
,
err
)
}
actual
:=
string
(
bytes
.
TrimSpace
(
buf
.
Bytes
()))
if
actual
!=
tt
.
expected
{
t
.
Errorf
(
"%q. expected %q, got %q"
,
tt
.
name
,
tt
.
expected
,
actual
)
}
buf
.
Reset
()
}
}
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