github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/unittest/irrecoverable.go (about)

     1  package unittest
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  // FailOnIrrecoverableError waits for either the done signal, or an error
    10  // to be sent over the error channel. If an error is observed, it is logged
    11  // and the test is failed.
    12  // Must be invoked as a goroutine.
    13  func FailOnIrrecoverableError(t *testing.T, done <-chan struct{}, errCh <-chan error) {
    14  	select {
    15  	case <-done:
    16  	case err := <-errCh:
    17  		assert.NoError(t, err, "observed unexpected irrecoverable error")
    18  	}
    19  }