Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Commit 759ab05

Browse files
committed
[issue-41] heroku app name for app name with spaces
when parse app name has spaces, the heroku app name we create should remove such spaces before creating the corresponding heroku app name
1 parent da58adc commit 759ab05

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

herokucmd/add.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ func selectHerokuApp(apps nameIDs, e *parsecli.Env) (*nameID, error) {
4343

4444
func getRandomAppName(app *parsecli.App) string {
4545
rand.Seed(time.Now().Unix())
46+
47+
namePrefix := strings.Join(strings.Fields(strings.ToLower(app.Name)), "")
48+
if namePrefix == "" {
49+
namePrefix = "parsoku"
50+
}
51+
4652
construct := fmt.Sprintf(
4753
"%s-%s-%d",
48-
strings.ToLower(app.Name),
54+
namePrefix,
4955
strings.ToLower(app.ApplicationID[:6]),
5056
rand.Intn(10000),
5157
)

herokucmd/add_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package herokucmd
2+
3+
import (
4+
"testing"
5+
6+
"github.com/ParsePlatform/parse-cli/parsecli"
7+
"github.com/facebookgo/ensure"
8+
)
9+
10+
func TestGetRandomAppName(t *testing.T) {
11+
app := &parsecli.App{Name: "test app", ApplicationID: "123456789"}
12+
name := getRandomAppName(app)
13+
ensure.StringContains(t, name, "testapp")
14+
}

0 commit comments

Comments
 (0)