Skip to content

Stop Eventually/Consistently with success #786

@grosser

Description

@grosser

as per https://onsi.github.io/gomega/#bailing-out-early
StopTrying is the only way to stop iteration without having to implement a custom matcher
but I'd like to also stop with a success, for example

	errChan := make(chan error)
	go func() {
		time.Sleep(10 * time.Second)
		errChan <- fmt.Errorf("error")
	}()
	Consistently(func() (bool) {
		select {
		case err := <-errChan:
			StopTrying("background task finished").Now()
			return true
		default:
			return true // actual check goes here
		}
	}, timeout, interval).Should(BeTrue())

to not fail, for example with StopTrying("background task stopped").Success()
or return return true, StopTrying("background task stopped").Success()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions