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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
51 deletions
+31
-51
list_test.go
cmd/helm/list_test.go
+31
-51
No files found.
cmd/helm/list_test.go
View file @
75ccc353
...
@@ -17,50 +17,44 @@ limitations under the License.
...
@@ -17,50 +17,44 @@ limitations under the License.
package
main
package
main
import
(
import
(
"bytes"
"io"
"regexp"
"testing"
"testing"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/release"
)
)
func
TestListCmd
(
t
*
testing
.
T
)
{
func
TestListCmd
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
releaseCase
{
name
string
args
[]
string
resp
[]
*
release
.
Release
expected
string
err
bool
}{
{
{
name
:
"with a release"
,
name
:
"with a release"
,
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
}),
},
},
expected
:
"thomas-guide"
,
expected
:
"thomas-guide"
,
},
},
{
{
name
:
"list"
,
name
:
"list"
,
args
:
[]
string
{},
rels
:
[]
*
release
.
Release
{
resp
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas"
}),
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
"
,
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"
,
name
:
"list, one deployed, one failed"
,
ar
gs
:
[]
string
{
"-q"
},
fla
gs
:
[]
string
{
"-q"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
},
expected
:
"thomas-guide
\n
atlas-guide"
,
expected
:
"thomas-guide
\n
atlas-guide"
,
},
},
{
{
name
:
"with a release, multiple flags"
,
name
:
"with a release, multiple flags"
,
ar
gs
:
[]
string
{
"--deleted"
,
"--deployed"
,
"--failed"
,
"-q"
},
fla
gs
:
[]
string
{
"--deleted"
,
"--deployed"
,
"--failed"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
},
...
@@ -69,9 +63,9 @@ func TestListCmd(t *testing.T) {
...
@@ -69,9 +63,9 @@ func TestListCmd(t *testing.T) {
expected
:
"thomas-guide
\n
atlas-guide"
,
expected
:
"thomas-guide
\n
atlas-guide"
,
},
},
{
{
name
:
"with a release, multiple flags"
,
name
:
"with a release, multiple flags"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
},
fla
gs
:
[]
string
{
"--all"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
},
...
@@ -79,9 +73,9 @@ func TestListCmd(t *testing.T) {
...
@@ -79,9 +73,9 @@ func TestListCmd(t *testing.T) {
expected
:
"thomas-guide
\n
atlas-guide"
,
expected
:
"thomas-guide
\n
atlas-guide"
,
},
},
{
{
name
:
"with a release, multiple flags, deleting"
,
name
:
"with a release, multiple flags, deleting"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
},
fla
gs
:
[]
string
{
"--all"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETING
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_DELETING
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
},
...
@@ -89,9 +83,9 @@ func TestListCmd(t *testing.T) {
...
@@ -89,9 +83,9 @@ func TestListCmd(t *testing.T) {
expected
:
"thomas-guide
\n
atlas-guide"
,
expected
:
"thomas-guide
\n
atlas-guide"
,
},
},
{
{
name
:
"namespace defined, multiple flags"
,
name
:
"namespace defined, multiple flags"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
,
"--namespace test123"
},
fla
gs
:
[]
string
{
"--all"
,
"-q"
,
"--namespace test123"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
Namespace
:
"test123"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
Namespace
:
"test123"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
Namespace
:
"test321"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
Namespace
:
"test321"
}),
},
},
...
@@ -99,18 +93,18 @@ func TestListCmd(t *testing.T) {
...
@@ -99,18 +93,18 @@ func TestListCmd(t *testing.T) {
expected
:
"thomas-guide"
,
expected
:
"thomas-guide"
,
},
},
{
{
name
:
"with a pending release, multiple flags"
,
name
:
"with a pending release, multiple flags"
,
ar
gs
:
[]
string
{
"--all"
,
"-q"
},
fla
gs
:
[]
string
{
"--all"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_PENDING_INSTALL
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_PENDING_INSTALL
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"atlas-guide"
,
StatusCode
:
release
.
Status_DEPLOYED
}),
},
},
expected
:
"thomas-guide
\n
atlas-guide"
,
expected
:
"thomas-guide
\n
atlas-guide"
,
},
},
{
{
name
:
"with a pending release, pending flag"
,
name
:
"with a pending release, pending flag"
,
ar
gs
:
[]
string
{
"--pending"
,
"-q"
},
fla
gs
:
[]
string
{
"--pending"
,
"-q"
},
re
sp
:
[]
*
release
.
Release
{
re
ls
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_PENDING_INSTALL
}),
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
:
"wild-idea"
,
StatusCode
:
release
.
Status_PENDING_UPGRADE
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-maps"
,
StatusCode
:
release
.
Status_PENDING_ROLLBACK
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"crazy-maps"
,
StatusCode
:
release
.
Status_PENDING_ROLLBACK
}),
...
@@ -120,7 +114,7 @@ func TestListCmd(t *testing.T) {
...
@@ -120,7 +114,7 @@ func TestListCmd(t *testing.T) {
},
},
{
{
name
:
"with old releases"
,
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"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
},
},
...
@@ -128,21 +122,7 @@ func TestListCmd(t *testing.T) {
...
@@ -128,21 +122,7 @@ func TestListCmd(t *testing.T) {
},
},
}
}
var
buf
bytes
.
Buffer
runReleaseCases
(
t
,
tests
,
func
(
c
*
helm
.
FakeClient
,
out
io
.
Writer
)
*
cobra
.
Command
{
for
_
,
tt
:=
range
tests
{
return
newListCmd
(
c
,
out
)
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
()
}
}
}
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