github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/testutils/assert.go (about)

     1  package testutils
     2  
     3  import (
     4  	"runtime"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func IsNotExistMessage() string {
    11  	if runtime.GOOS == "windows" {
    12  		return "The system cannot find" // some error messages use "path" and some use "file"
    13  	} else {
    14  		return "no such file or directory"
    15  	}
    16  
    17  }
    18  
    19  // Asserts the given error indicates a file doesn't exist.
    20  // Uses string matching instead of type-checking, to workaround
    21  // libraries that wrap the error.
    22  func AssertIsNotExist(t *testing.T, err error) {
    23  	assert.Contains(t, err.Error(), IsNotExistMessage())
    24  }