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
75ccc353
Commit
75ccc353
authored
Mar 08, 2018
by
Arash Deshmeh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(helm): remove duplicate test code from cmd/helm/list_test. Closes #3637
Signed-off-by:
Arash Deshmeh
<
adeshmeh@ca.ibm.com
>
parent
c3124646
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
44 deletions
+24
-44
list_test.go
cmd/helm/list_test.go
+24
-44
No files found.
cmd/helm/list_test.go
View file @
75ccc353
...
...
@@ -17,41 +17,35 @@ limitations under the License.
package
main
import
(
"bytes"
"regexp"
"io"
"testing"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
)
func
TestListCmd
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
args
[]
string
resp
[]
*
release
.
Release
expected
string
err
bool
}{
tests
:=
[]
releaseCase
{
{
name
:
"with a release"
,
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
}),
},
expected
:
"thomas-guide"
,
},
{
name
:
"list"
,
args
:
[]
string
{},
resp
:
[]
*
release
.
Release
{
rels
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"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
"
,
},
{
name
:
"list, one deployed, one failed"
,
ar
gs
:
[]
string
{
"-q"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"-q"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
...
...
@@ -59,8 +53,8 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"with a release, multiple flags"
,
ar
gs
:
[]
string
{
"--deleted"
,
"--deployed"
,
"--failed"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"--deleted"
,
"--deployed"
,
"--failed"
,
"-q"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
...
...
@@ -70,8 +64,8 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"with a release, multiple flags"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"--all"
,
"-q"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
...
...
@@ -80,8 +74,8 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"with a release, multiple flags, deleting"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"--all"
,
"-q"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETING
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
...
...
@@ -90,8 +84,8 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"namespace defined, multiple flags"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
,
"--namespace test123"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"--all"
,
"-q"
,
"--namespace test123"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
Namespace
:
"test123"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
Namespace
:
"test321"
}),
},
...
...
@@ -100,8 +94,8 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"with a pending release, multiple flags"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"--all"
,
"-q"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_PENDING_INSTALL
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
...
...
@@ -109,8 +103,8 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"with a pending release, pending flag"
,
ar
gs
:
[]
string
{
"--pending"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
fla
gs
:
[]
string
{
"--pending"
,
"-q"
},
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_PENDING_INSTALL
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"wild-idea"
,
StatusCode
:
release
.
Status_PENDING_UPGRADE
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-maps"
,
StatusCode
:
release
.
Status_PENDING_ROLLBACK
}),
...
...
@@ -120,7 +114,7 @@ func TestListCmd(t *testing.T) {
},
{
name
:
"with old releases"
,
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
},
...
...
@@ -128,21 +122,7 @@ func TestListCmd(t *testing.T) {
},
}
var
buf
bytes
.
Buffer
for
_
,
tt
:=
range
tests
{
c
:=
&
helm
.
FakeClient
{
Rels
:
tt
.
resp
,
}
cmd
:=
newListCmd
(
c
,
&
buf
)
cmd
.
ParseFlags
(
tt
.
args
)
err
:=
cmd
.
RunE
(
cmd
,
tt
.
args
)
if
(
err
!=
nil
)
!=
tt
.
err
{
t
.
Errorf
(
"%q. expected error: %v, got %v"
,
tt
.
name
,
tt
.
err
,
err
)
}
re
:=
regexp
.
MustCompile
(
tt
.
expected
)
if
!
re
.
Match
(
buf
.
Bytes
())
{
t
.
Errorf
(
"%q. expected
\n
%q
\n
got
\n
%q"
,
tt
.
name
,
tt
.
expected
,
buf
.
String
())
}
buf
.
Reset
()
}
runReleaseCases
(
t
,
tests
,
func
(
c
*
helm
.
FakeClient
,
out
io
.
Writer
)
*
cobra
.
Command
{
return
newListCmd
(
c
,
out
)
})
}
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