Example #1
0
// Wait TODO(rjeczalik): document
func (cli *CLI) Wait(ctx *cli.Context) {
	if err := cli.init(ctx); err != nil {
		cli.Err(err)
		return
	}
	p := cli.p.String()
	if p == "" || p == ".*" {
		cli.Err("pulsecli: a --project name is missing")
		return
	}
	id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
	if err != nil {
		cli.Err(err)
		return
	}
	select {
	case <-time.After(cli.d):
		err = pulse.ErrTimeout
	case err = <-util.Wait(cli.c, time.Second, p, id):
	}
	if err != nil {
		cli.Err(err)
		return
	}
}
Example #2
0
func accept(t *testing.T, p string, ok bool) {
	c, teardown := fixture(t)
	defer teardown()
	reqid, err := c.Trigger(p)
	if err != nil {
		t.Fatalf("error triggering build %q: %v", p, err)
	}
	if len(reqid) != 1 {
		t.Fatalf("invalid length of the trigger response: len(reqid)=%d", len(reqid))
	}
	id, err := c.BuildID(reqid[0])
	if err != nil {
		t.Fatalf("error requesting build ID: %v", err)
	}
	done := util.Wait(c, 125*time.Millisecond, p, id)
	select {
	case <-done:
	case <-time.After(time.Minute):
	}
	build, err := c.BuildResult(p, id)
	if err != nil {
		t.Fatalf("error requesting build state: %v", err)
	}
	if len(build) != 1 {
		t.Errorf("expected len(build) to be 1, was %d instead", len(build))
	}
	if !util.Pending(build) {
		if !build[0].Complete {
			t.Errorf("expected p=%q build=%d to be completed", p, id)
		}
		if build[0].Success != ok {
			t.Errorf("expected p=%q build=%d to be successful=%v", p, id, ok)
		}
	}
}