Пример #1
0
func TestMemcache(t *testing.T) {
	tc := testutil.EndToEndTest(t)

	memcache := &aeintegrate.App{
		Name:      "mem",
		Dir:       tc.Path("docs", "managed_vms", "memcache"),
		ProjectID: tc.ProjectID,
	}

	bodyShouldContain(t, memcache, "/", "Count")
}
Пример #2
0
func TestHelloWorld(t *testing.T) {
	tc := testutil.EndToEndTest(t)

	helloworld := &aeintegrate.App{
		Name:      "hw",
		Dir:       tc.Path("docs", "managed_vms", "helloworld"),
		ProjectID: tc.ProjectID,
	}

	bodyShouldContain(t, helloworld, "/", "Hello world!")
}
func TestHelloWorld(t *testing.T) {
	tc := testutil.EndToEndTest(t)
	limit.Wait(context.Background())

	helloworld := &aeintegrate.App{
		Name:      "hw",
		Dir:       tc.Path("appengine_flexible", "helloworld"),
		ProjectID: tc.ProjectID,
	}
	defer helloworld.Cleanup()

	bodyShouldContain(t, helloworld, "/", "Hello world!")
}
func TestStorage(t *testing.T) {
	tc := testutil.EndToEndTest(t)
	limit.Wait(context.Background())

	storage := &aeintegrate.App{
		Name:      "st",
		Dir:       tc.Path("appengine_flexible", "storage"),
		ProjectID: tc.ProjectID,
		Env: map[string]string{
			"GCLOUD_STORAGE_BUCKET": tc.ProjectID,
		},
	}
	defer storage.Cleanup()

	if deployed := bodyShouldContain(t, storage, "/", "<form method"); !deployed {
		return
	}

	// Requests may still not be routed correctly. Wait a little while.
	time.Sleep(10 * time.Second)

	url, _ := storage.URL("/upload")
	var body bytes.Buffer
	req, err := http.NewRequest("POST", url, &body)
	if err != nil {
		t.Fatalf("NewRequest: %v", err)
	}
	const filename = "flexible-storage-e2e"
	w := multipart.NewWriter(&body)
	fw, err := w.CreateFormFile("file", filename)
	if err != nil {
		t.Fatalf("CreateFormFile: %v", err)
	}
	fw.Write([]byte("hello"))
	w.Close()
	req.Header.Set("Content-Type", w.FormDataContentType())
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		t.Fatalf("Do: %v", err)
	}
	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		t.Fatalf("could not read body: %v", err)
	}
	if shouldContain := "Successful! URL"; !strings.Contains(string(b), shouldContain) {
		t.Errorf("Want resp to contain %q, got %q", shouldContain, string(b))
	}
	if shouldContain := filename; !strings.Contains(string(b), shouldContain) {
		t.Errorf("Want resp to contain %q, got %q", shouldContain, string(b))
	}
}
Пример #5
0
func TestDatastore(t *testing.T) {
	tc := testutil.EndToEndTest(t)

	datastore := &aeintegrate.App{
		Name:      "ds",
		Dir:       tc.Path("docs", "managed_vms", "datastore"),
		ProjectID: tc.ProjectID,
		Env: map[string]string{
			"GCLOUD_DATASET_ID": tc.ProjectID,
		},
	}

	bodyShouldContain(t, datastore, "/", "Successfully stored")
}
func TestMemcache(t *testing.T) {
	t.Skip("Doesn't work on Flex.")

	tc := testutil.EndToEndTest(t)
	limit.Wait(context.Background())

	memcache := &aeintegrate.App{
		Name:      "mem",
		Dir:       tc.Path("appengine_flexible", "memcache"),
		ProjectID: tc.ProjectID,
	}
	defer memcache.Cleanup()

	bodyShouldContain(t, memcache, "/", "Count")
}
func TestDatastore(t *testing.T) {
	tc := testutil.EndToEndTest(t)
	limit.Wait(context.Background())

	datastore := &aeintegrate.App{
		Name:      "ds",
		Dir:       tc.Path("appengine_flexible", "datastore"),
		ProjectID: tc.ProjectID,
		Env: map[string]string{
			"GCLOUD_DATASET_ID": tc.ProjectID,
		},
	}
	defer datastore.Cleanup()

	bodyShouldContain(t, datastore, "/", "Successfully stored")
}