예제 #1
0
func TestConvoxInstallSTDINCredentials(t *testing.T) {
	stackId := "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83"
	cycles := []awsutil.Cycle{
		awsutil.Cycle{
			awsutil.Request{"/", "", "/./"},
			awsutil.Response{200, `<CreateStackResult><StackId>` + stackId + `</StackId></CreateStackResult>`},
		},
		awsutil.Cycle{
			awsutil.Request{"/", "", ""},
			awsutil.Response{200, ""},
		},
	}

	handler := awsutil.NewHandler(cycles)
	s := httptest.NewServer(handler)
	defaults.DefaultConfig.Endpoint = &s.URL

	defer s.Close()

	latest, _ := version.Latest()

	test.Runs(t,
		test.ExecRun{
			Command: "convox install",
			Exit:    0,
			Env:     map[string]string{"AWS_ENDPOINT_URL": s.URL, "AWS_REGION": "test"},
			Stdin:   `{"Credentials":{"AccessKeyId":"FOO","SecretAccessKey":"BAR","Expiration":"2015-09-17T14:09:41Z"}}`,
			Stdout:  Banner + "\nInstalling Convox (" + latest + ")...\n" + stackId + "\n",
		},
	)
}
예제 #2
0
파일: rack_test.go 프로젝트: gmelika/rack
func TestRackUpdateStable(t *testing.T) {
	versions, err := version.All()
	require.Nil(t, err)

	stable, err := versions.Resolve("stable")
	require.Nil(t, err)

	ts := testServer(t,
		test.Http{Method: "PUT", Body: fmt.Sprintf("version=%s", stable.Version), Path: "/system", Code: 200, Response: client.System{
			Name:    "mysystem",
			Version: "ver",
			Count:   1,
			Type:    "type",
		}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox rack update",
			Exit:    0,
			Stdout:  fmt.Sprintf("Name     mysystem\nStatus   \nVersion  ver\nCount    1\nType     type\n\nUpdating to version: %s\n", stable.Version),
		},
	)
}
예제 #3
0
파일: login_test.go 프로젝트: convox/rack
func TestInvalidLogin(t *testing.T) {
	temp, _ := ioutil.TempDir("", "convox-test")

	ts := testServer(t,
		test.Http{Method: "GET", Path: "/apps", Code: 401, Response: "unauthorized"},
		test.Http{Method: "GET", Path: "/auth", Code: 404, Response: "not found"},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: fmt.Sprintf("convox login --password foobar %s", ts.URL),
			Env:     map[string]string{"CONVOX_CONFIG": temp},
			Exit:    1,
			Stderr:  "ERROR: invalid login\nHave you created an account at https://convox.com/signup?\n",
		},
		test.ExecRun{
			Command: "convox login --password foobar BAD",
			Env:     map[string]string{"CONVOX_CONFIG": temp},
			Exit:    1,
			Stderr:  "ERROR",
		},
	)
}
예제 #4
0
파일: api_test.go 프로젝트: gmelika/rack
func TestApiGet(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "GET", Path: "/foo", Code: 200, Response: "bar"},
	)
	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox api get /foo",
			Exit:    0,
			Stdout:  "\"bar\"\n",
		},
	)
}
예제 #5
0
func TestServicesCreate(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "POST", Path: "/services", Body: "name=syslog-1234&type=syslog&url=tcp%2Btls%3A%2F%2Flogs1.example.com%3A12345", Code: 200, Response: client.Service{}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox services create syslog --name=syslog-1234 --url=tcp+tls://logs1.example.com:12345",
			Exit:    0,
			Stdout:  "Creating syslog-1234 (syslog: name=\"syslog-1234\" url=\"tcp+tls://logs1.example.com:12345\")... CREATING\n",
		},
	)
}
예제 #6
0
func TestServicesDelete(t *testing.T) {
	tsd := testServer(t,
		test.Http{Method: "DELETE", Path: "/services/syslog-1234", Code: 200, Response: client.Service{}},
	)

	defer tsd.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox services delete syslog-1234",
			Exit:    0,
			Stdout:  "Deleting syslog-1234... DELETING\n",
		},
	)
}
예제 #7
0
파일: apps_test.go 프로젝트: jbuck/rack
func TestAppsCreate(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "POST", Path: "/apps", Code: 200, Response: client.App{}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox apps create foobar",
			Exit:    0,
			Stdout:  "Creating app foobar... CREATING\n",
		},
	)
}
예제 #8
0
파일: apps_test.go 프로젝트: jbuck/rack
func TestAppsCreateFail(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "POST", Path: "/apps", Code: 403, Response: client.Error{Error: "app already exists"}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox apps create foobar",
			Exit:    1,
			Stdout:  "Creating app foobar... ",
			Stderr:  "ERROR: app already exists\n",
		},
	)
}
예제 #9
0
func TestDeployPreventAgainstCreating(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "GET", Path: "/apps/foo", Code: 200, Response: client.App{Name: "foo", Status: "creating"}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox deploy --app foo",
			Exit:    1,
			Stdout:  "Deploying foo\n",
			Stderr:  "ERROR: app is still creating: foo\n",
		},
	)
}
예제 #10
0
func TestConvoxInstallValidateStackName(t *testing.T) {
	stackId := "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83"
	cycles := []awsutil.Cycle{
		awsutil.Cycle{
			awsutil.Request{"/", "", "/./"},
			awsutil.Response{200, `<CreateStackResult><StackId>` + stackId + `</StackId></CreateStackResult>`},
		},
		awsutil.Cycle{
			awsutil.Request{"/", "", ""},
			awsutil.Response{200, ""},
		},
	}

	handler := awsutil.NewHandler(cycles)
	s := httptest.NewServer(handler)
	defer s.Close()

	os.Setenv("AWS_ENDPOINT", s.URL)

	latest, _ := version.Latest()

	test.Runs(t,
		test.ExecRun{
			Command: "convox install --stack-name valid",
			Exit:    0,
			Env:     map[string]string{"AWS_ENDPOINT_URL": s.URL, "AWS_REGION": "test"},
			Stdin:   `{"Credentials":{"AccessKeyId":"FOO","SecretAccessKey":"BAR","Expiration":"2015-09-17T14:09:41Z"}}`,
			Stdout:  Banner + "\nInstalling Convox (" + latest + ")...\n" + stackId + "\n",
		},

		test.ExecRun{
			Command: "convox install --stack-name Invalid",
			Exit:    1,
			Env:     map[string]string{"AWS_ENDPOINT_URL": s.URL, "AWS_REGION": "test"},
			Stdin:   `{"Credentials":{"AccessKeyId":"FOO","SecretAccessKey":"BAR","Expiration":"2015-09-17T14:09:41Z"}}`,
			Stderr:  `ERROR: Stack name is invalid, must match [a-z0-9-]*`,
		},

		test.ExecRun{
			Command: "convox install --stack-name in_valid",
			Exit:    1,
			Env:     map[string]string{"AWS_ENDPOINT_URL": s.URL, "AWS_REGION": "test"},
			Stdin:   `{"Credentials":{"AccessKeyId":"FOO","SecretAccessKey":"BAR","Expiration":"2015-09-17T14:09:41Z"}}`,
			Stderr:  `ERROR: Stack name is invalid, must match [a-z0-9-]*`,
		},
	)
}
예제 #11
0
func TestServices(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "GET", Path: "/services", Code: 200, Response: client.Services{
			client.Service{Name: "syslog-1234", Type: "syslog", Status: "running"},
		}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox services",
			Exit:    0,
			Stdout:  "NAME         TYPE    STATUS\nsyslog-1234  syslog  running\n",
		},
	)
}
예제 #12
0
func TestBuildsCreateReturnsNoBuild(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "GET", Path: "/apps/foo", Code: 200, Response: client.App{Name: "foo", Status: "running"}},
		test.Http{Method: "POST", Path: "/apps/foo/builds", Body: "repo=https%3A%2F%2Fexample.org", Code: 200, Response: client.Build{}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox build https://example.org --app foo",
			Exit:    1,
			Stdout:  "",
			Stderr:  "ERROR: unable to fetch build id\n",
		},
	)
}
예제 #13
0
파일: apps_test.go 프로젝트: jbuck/rack
func TestApps(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "GET", Path: "/apps", Code: 200, Response: client.Apps{
			client.App{Name: "sinatra", Status: "running"},
		}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox apps",
			Exit:    0,
			Stdout:  "APP      STATUS \nsinatra  running\n",
		},
	)
}
예제 #14
0
파일: login_test.go 프로젝트: convox/rack
func TestLogin(t *testing.T) {
	temp, _ := ioutil.TempDir("", "convox-test")

	ts := testServer(t,
		test.Http{Method: "GET", Path: "/apps", Code: 200, Response: client.Apps{}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: fmt.Sprintf("convox login --password foobar %s", ts.URL),
			Env:     map[string]string{"CONVOX_CONFIG": temp},
			Exit:    0,
			Stdout:  "Logged in successfully.\n",
		},
	)
}
예제 #15
0
파일: start_test.go 프로젝트: soulware/rack
func TestStartWithMapEnv(t *testing.T) {
	temp, _ := ioutil.TempDir("", "convox-test")
	appDir := temp + "/app"
	os.Mkdir(appDir, 0777)
	defer os.RemoveAll(appDir)

	d1 := []byte(manifestMapEnv)
	ioutil.WriteFile(appDir+"/docker-compose.yml", d1, 0777)

	test.Runs(t,
		test.ExecRun{
			Command:  fmt.Sprintf("convox start"),
			Dir:      appDir,
			Env:      map[string]string{"CONVOX_CONFIG": temp},
			OutMatch: "docker run",
			Exit:     0,
		},
	)
}
예제 #16
0
파일: start_test.go 프로젝트: soulware/rack
func TestStartWithMissingEnv(t *testing.T) {
	temp, _ := ioutil.TempDir("", "convox-test")
	appDir := temp + "/app"
	os.Mkdir(appDir, 0777)
	defer os.RemoveAll(appDir)

	d1 := []byte(manifestRequired)
	ioutil.WriteFile(appDir+"/docker-compose.yml", d1, 0777)

	test.Runs(t,
		test.ExecRun{
			Command: fmt.Sprintf("convox start"),
			Dir:     appDir,
			Env:     map[string]string{"CONVOX_CONFIG": temp},
			Exit:    1,
			Stderr:  "ERROR: env expected: FOO",
		},
	)
}
예제 #17
0
파일: rack_test.go 프로젝트: gmelika/rack
func TestRackUpdateSpecified(t *testing.T) {
	ts := testServer(t,
		test.Http{Method: "PUT", Body: "version=20150909014908", Path: "/system", Code: 200, Response: client.System{
			Name:    "mysystem",
			Version: "ver",
			Count:   1,
			Type:    "type",
		}},
	)

	defer ts.Close()

	test.Runs(t,
		test.ExecRun{
			Command: "convox rack update 20150909014908",
			Exit:    0,
			Stdout:  "Name     mysystem\nStatus   \nVersion  ver\nCount    1\nType     type\n\nUpdating to version: 20150909014908\n",
		},
	)
}