コード例 #1
0
func bodyShouldContain(t *testing.T, p *aeintegrate.App, path, shouldContain string) bool {
	if p.Deployed() {
		t.Fatalf("[%s] expected non-deployed app", p.Name)
	}

	if err := p.Deploy(); err != nil {
		t.Fatalf("could not deploy %s: %v", p.Name, err)
	}

	url, _ := p.URL("")
	log.Printf("(%s) Deployed to %s", p.Name, url)

	timeout := time.Now().Add(4 * time.Minute)

	for ; ; time.Sleep(time.Second) {
		resp, err := p.Get(path)
		if err != nil {
			t.Logf("Get: %v", err)
			continue
		}
		b, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			t.Logf("could not read body: %v", err)
			continue
		}
		if strings.Contains(string(b), shouldContain) {
			return true
		}
		if time.Now().After(timeout) {
			t.Errorf("wanted to contain %q, but got body: %q", shouldContain, string(b))
			return false
		}
	}
}
コード例 #2
0
func bodyShouldContain(t *testing.T, p *aeintegrate.App, path, shouldContain string) {
	if p.Deployed() {
		t.Fatalf("[%s] expected non-deployed app", p.Name)
	}

	if err := p.Deploy(); err != nil {
		t.Fatalf("could not deploy %s: %v", p.Name, err)
	}

	defer p.Cleanup()

	resp, err := p.Get(path)
	if err != nil {
		t.Fatal(err)
	}

	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		t.Fatalf("could not read body: %v", err)
	}

	if !strings.Contains(string(b), shouldContain) {
		t.Fatalf("wanted to contain %q, but got body: %q", shouldContain, string(b))
	}
}