示例#1
0
// NewResultForward tests Resolver.Forward().
func (t *TurnRunnerSuite) NewResultForward() async.R {
	expected := fmt.Errorf("some error")
	r, s := async.NewR()
	async.When(async.Done(), func() {
		s.Forward(async.NewError(expected))
	})
	return async.When(r, func(err error) error {
		if err != expected {
			return fmt.Errorf("Got: %v, Want: %v", err, expected)
		}
		return nil
	})
}
示例#2
0
// NewResultForwarded tests a When on a forwarded result resolves correctly.
func (t *TurnRunnerSuite) NewResultForwarded() async.R {
	expected := fmt.Errorf("some error")
	r, s := async.NewR()

	// Forward the result synchronously causing the When to be directly enqueued on the error.
	s.Forward(async.NewError(expected))

	return async.When(r, func(err error) error {
		if err != expected {
			return fmt.Errorf("Got: %v, Want: %v", err, expected)
		}
		return nil
	})
}