Ejemplo n.º 1
0
func TestAppShowWithAppNotFound(t *testing.T) {
	aws := test.StubAws(
		test.DescribeStackNotFound("convox-test-bar"),
		test.DescribeStackNotFound("bar"),
	)
	defer aws.Close()

	test.AssertStatus(t, 404, "GET", "http://convox/apps/bar", nil)
}
Ejemplo n.º 2
0
// Test the primary path: creating an app on a `convox` rack
// Return to testing against a `convox-test` rack afterwards
func TestAppCreate(t *testing.T) {
	r := os.Getenv("RACK")
	os.Setenv("RACK", "convox")
	defer os.Setenv("RACK", r)

	aws := test.StubAws(
		test.DescribeStackNotFound("application"),
		test.CreateAppStackCycle("convox-application"),
		test.DescribeAppStackCycle("convox-application"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"application"}}
	body := test.HTTPBody("POST", "http://convox/apps", val)

	if assert.NotEqual(t, "", body) {
		var resp map[string]string
		err := json.Unmarshal([]byte(body), &resp)

		if assert.Nil(t, err) {
			assert.Equal(t, "application", resp["name"])
			assert.Equal(t, "running", resp["status"])
		}
	}
}
Ejemplo n.º 3
0
func TestServiceWebhookURL(t *testing.T) {
	provider := StubAwsProvider(
		test.DescribeStackNotFound("convox-mywebhook"),
		test.DescribeStackNotFound("mywebhook"),
		cycleServiceCreateWebhook,
	)
	defer provider.Close()

	params := map[string]string{
		"url": "https://www.example.com",
	}

	url := "http://notifications.example.org/sns?endpoint=https%3A%2F%2Fwww.example.com"
	s, err := provider.ServiceCreate("mywebhook", "webhook", params)

	if assert.Nil(t, err) {
		assert.Equal(t, url, s.Parameters["Url"])
	}
}
Ejemplo n.º 4
0
func TestAppCreateWithAlreadyExists(t *testing.T) {
	aws := test.StubAws(
		test.DescribeStackNotFound("application"),
		test.CreateAppStackExistsCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"application"}}
	body := test.AssertStatus(t, 403, "POST", "http://convox/apps", val)
	assert.Equal(t, "{\"error\":\"there is already an app named application (running)\"}", body)
}
Ejemplo n.º 5
0
func TestAppShowUnbound(t *testing.T) {
	aws := test.StubAws(
		test.DescribeStackNotFound("convox-test-bar"),
		test.DescribeAppStackCycle("bar"),
	)
	defer aws.Close()

	body := test.HTTPBody("GET", "http://convox/apps/bar", nil)

	var resp map[string]string
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, "bar", resp["name"])
		assert.Equal(t, "running", resp["status"])
	}
}
Ejemplo n.º 6
0
func TestAppDeleteWithAppNotFound(t *testing.T) {
	aws := stubAws(test.DescribeStackNotFound("bar"))
	defer aws.Close()

	AssertStatus(t, 404, "DELETE", "http://convox/apps/bar", nil)
}