Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Updating e2e tests with env globals
Browse files Browse the repository at this point in the history
Signed-off-by: bryanl <bryanliles@gmail.com>
  • Loading branch information
bryanl committed Apr 6, 2018
1 parent acf9963 commit e79264c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/actions.go
Expand Up @@ -42,6 +42,7 @@ const (
actionParamDiff
actionParamList
actionParamSet
actionParamUnset
actionPkgDescribe
actionPkgInstall
actionPkgList
Expand Down Expand Up @@ -79,6 +80,7 @@ var (
actionModuleList: actions.RunModuleList,
// actionParamDiff
actionParamDelete: actions.RunParamDelete,
actionParamUnset: actions.RunParamDelete,
actionParamList: actions.RunParamList,
actionParamSet: actions.RunParamSet,
actionPkgDescribe: actions.RunPkgDescribe,
Expand Down
2 changes: 1 addition & 1 deletion cmd/param_delete.go
Expand Up @@ -28,7 +28,7 @@ var (
)

var paramDeleteCmd = &cobra.Command{
Use: "delete <component-name> <param-key>",
Use: "delete [component-name] <param-key>",
Short: paramShortDesc["delete"],
RunE: func(cmd *cobra.Command, args []string) error {
var name string
Expand Down
14 changes: 13 additions & 1 deletion cmd/param_delete_test.go
Expand Up @@ -24,7 +24,7 @@ import (
func Test_paramDeleteCmd(t *testing.T) {
cases := []cmdTestCase{
{
name: "in general",
name: "with a component",
args: []string{"param", "delete", "component-name", "param-name"},
action: actionParamDelete,
expected: map[string]interface{}{
Expand All @@ -35,6 +35,18 @@ func Test_paramDeleteCmd(t *testing.T) {
actions.OptionIndex: 0,
},
},
{
name: "without a component",
args: []string{"param", "delete", "param-name", "--env", "default"},
action: actionParamDelete,
expected: map[string]interface{}{
actions.OptionApp: ka,
actions.OptionName: "",
actions.OptionPath: "param-name",
actions.OptionEnvName: "default",
actions.OptionIndex: 0,
},
},
}

runTestCmd(t, cases)
Expand Down
29 changes: 29 additions & 0 deletions e2e/param_test.go
Expand Up @@ -74,6 +74,23 @@ var _ = Describe("ks param", func() {
assertOutput("param/delete/env.txt", o.stdout)
})
})

FContext("removing environment global", func() {
BeforeEach(func() {
o := a.runKs("param", "set", "department", "engineering", "--env", "default")
assertExitStatus(o, 0)
})

JustBeforeEach(func() {
o := a.runKs("param", "delete", "department", "--env", "default")
assertExitStatus(o, 0)
})

It("removes the value", func() {
o := a.paramList("--env", "default")
assertOutput("param/delete/env-global.txt", o.stdout)
})
})
})

Describe("list", func() {
Expand Down Expand Up @@ -124,6 +141,18 @@ var _ = Describe("ks param", func() {

})
})

FContext("setting environment global", func() {
JustBeforeEach(func() {
o := a.runKs("param", "set", "department", "engineering", "--env", "default")
assertExitStatus(o, 0)
})

It("sets the value", func() {
o := a.paramList("--env", "default")
assertOutput("param/set/env-global.txt", o.stdout)
})
})
})

})
10 changes: 10 additions & 0 deletions e2e/testdata/output/param/delete/env-global.txt
@@ -0,0 +1,10 @@
COMPONENT INDEX PARAM VALUE
========= ===== ===== =====
guestbook-ui 0 containerPort 80
guestbook-ui 0 env-value 2
guestbook-ui 0 image "gcr.io/heptio-images/ks-guestbook-demo:0.1"
guestbook-ui 0 local-value 1
guestbook-ui 0 name "guestbook-ui"
guestbook-ui 0 replicas 1
guestbook-ui 0 servicePort 80
guestbook-ui 0 type "ClusterIP"
9 changes: 9 additions & 0 deletions e2e/testdata/output/param/set/env-global.txt
@@ -0,0 +1,9 @@
COMPONENT INDEX PARAM VALUE
========= ===== ===== =====
guestbook-ui 0 containerPort 80
guestbook-ui 0 department "engineering"
guestbook-ui 0 image "gcr.io/heptio-images/ks-guestbook-demo:0.1"
guestbook-ui 0 name "guestbook-ui"
guestbook-ui 0 replicas 1
guestbook-ui 0 servicePort 80
guestbook-ui 0 type "ClusterIP"

0 comments on commit e79264c

Please sign in to comment.