-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapps_test.go
More file actions
80 lines (64 loc) · 1.61 KB
/
apps_test.go
File metadata and controls
80 lines (64 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package cmd
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"os"
"testing"
"github.com/arschles/assert"
"github.com/deis/workflow-cli/pkg/git"
"github.com/deis/workflow-cli/pkg/testutil"
)
type expandURLCases struct {
Input string
Expected string
}
func TestExpandUrl(t *testing.T) {
checks := []expandURLCases{
{
Input: "test.com",
Expected: "test.com",
},
{
Input: "test",
Expected: "test.foo.com",
},
}
for _, check := range checks {
out := expandURL("deis.foo.com", check.Input)
if out != check.Expected {
t.Errorf("Expected %s, Got %s", check.Expected, out)
}
}
}
func TestRemoteExists(t *testing.T) {
cf, server, err := testutil.NewTestServerAndClient()
if err != nil {
t.Fatal(err)
}
defer server.Close()
server.Mux.HandleFunc("/v2/apps/", func(w http.ResponseWriter, r *http.Request) {
testutil.SetHeaders(w)
fmt.Fprintf(w, `{
"owner": "jkirk",
"id": "foo",
"created": "2014-01-01T00:00:00UTC",
"updated": "2014-01-01T00:00:00UTC",
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
}`)
})
// create a remote first before running apps:create
dir, err := ioutil.TempDir("", "apps")
assert.NoErr(t, err)
defer os.RemoveAll(dir)
assert.NoErr(t, os.Chdir(dir))
assert.NoErr(t, git.Init())
assert.NoErr(t, git.CreateRemote("localhost", "deis", "appname"))
var b bytes.Buffer
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
err = cmdr.AppCreate("foo", "", "deis", false)
assert.Equal(t, err.Error(), `A git remote with the name deis already exists. To overwrite this remote run:
deis git:remote --force --remote deis --app foo`,
"output")
}