本文整理匯總了Golang中github.com/convox/rack/test.Runs函數的典型用法代碼示例。如果您正苦於以下問題:Golang Runs函數的具體用法?Golang Runs怎麽用?Golang Runs使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Runs函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestConvoxInstallSTDINCredentials
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: TestRackUpdateStable
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: TestInvalidLogin
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: TestApiGet
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: TestServicesCreate
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: TestServicesDelete
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: TestAppsCreate
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: TestAppsCreateFail
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: TestDeployPreventAgainstCreating
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: TestConvoxInstallValidateStackName
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: TestServices
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: TestBuildsCreateReturnsNoBuild
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: TestApps
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: TestLogin
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: TestStartWithMapEnv
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,
},
)
}