github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/k8s/portforward/error_test.go (about)

     1  package portforward
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestManyErrors(t *testing.T) {
    11  	h := newErrorHandler()
    12  	defer h.Close()
    13  
    14  	go func() {
    15  		h.Stop(fmt.Errorf("my error 1"))
    16  	}()
    17  	go func() {
    18  		h.Stop(fmt.Errorf("my error 2"))
    19  	}()
    20  	go func() {
    21  		h.Stop(fmt.Errorf("my error 3"))
    22  	}()
    23  
    24  	err := <-h.Done()
    25  	assert.Contains(t, err.Error(), "my error")
    26  }
    27  
    28  func TestNoErrors(t *testing.T) {
    29  	h := newErrorHandler()
    30  	go func() {
    31  		h.Close()
    32  	}()
    33  
    34  	err := <-h.Done()
    35  	assert.Nil(t, err)
    36  }