Skip to content

Commit 70df6e0

Browse files
author
Seth Goings
authored
Merge pull request #149 from sgoings/shortcuts-test
feat(shortcuts): add shortcuts test
2 parents 5615bb4 + 6e2954d commit 70df6e0

4 files changed

Lines changed: 46 additions & 7 deletions

File tree

cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func ConfigSet(appID string, configVars []string) error {
9292

9393
// NOTE(bacongobbler): check if the user is using the old way to set healthchecks. If so,
9494
// send them a deprecation notice.
95-
for key, _ := range configMap {
95+
for key := range configMap {
9696
if strings.Contains(key, "HEALTHCHECK_") {
9797
fmt.Println(`Hey there! We've noticed that you're using 'deis config:set HEALTHCHECK_URL'
9898
to set up healthchecks. This functionality has been deprecated. In the future, please use

cmd/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Examples: username=bob password=s3cur3pw1`, item)
124124
}
125125

126126
if parts[0] != "username" && parts[0] != "password" {
127-
return "", "", fmt.Errorf(`%s is invalid. Valid keys are "username" or "password".`, parts[0])
127+
return "", "", fmt.Errorf(`%s is invalid. Valid keys are "username" or "password"`, parts[0])
128128
}
129129

130130
return parts[0], parts[1], nil

cmd/shortcuts.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ import (
77
"github.com/deis/workflow-cli/cli"
88
)
99

10-
// Shortcuts displays all relevant shortcuts for the CLI.
10+
// ShortcutsList displays all relevant shortcuts for the CLI.
1111
func ShortcutsList() error {
12+
fmt.Println(sortShortcuts())
13+
14+
return nil
15+
}
16+
17+
func sortShortcuts() string {
1218
var (
13-
strBuilder string = ""
19+
strBuilder string
1420
keys []string
1521
)
1622

@@ -25,7 +31,5 @@ func ShortcutsList() error {
2531
strBuilder += fmt.Sprintf("%s -> %s\n", k, cli.Shortcuts[k])
2632
}
2733

28-
fmt.Println(strBuilder)
29-
30-
return nil
34+
return strBuilder
3135
}

cmd/shortcuts_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package cmd
2+
3+
import (
4+
"testing"
5+
)
6+
7+
8+
func TestShortcutsList(t *testing.T) {
9+
t.Parallel()
10+
11+
expected := `create -> apps:create
12+
destroy -> apps:destroy
13+
info -> apps:info
14+
login -> auth:login
15+
logout -> auth:logout
16+
logs -> apps:logs
17+
open -> apps:open
18+
passwd -> auth:passwd
19+
pull -> builds:create
20+
register -> auth:register
21+
rollback -> releases:rollback
22+
run -> apps:run
23+
scale -> ps:scale
24+
sharing -> perms:list
25+
sharing:add -> perms:create
26+
sharing:list -> perms:list
27+
sharing:remove -> perms:delete
28+
whoami -> auth:whoami
29+
`
30+
actual := sortShortcuts()
31+
if actual != expected {
32+
t.Errorf("Expected %s, Got %s", expected, actual)
33+
}
34+
35+
}

0 commit comments

Comments
 (0)