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

     1  package watch
     2  
     3  import (
     4  	"runtime"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"github.com/tilt-dev/tilt/internal/testutils/tempdir"
    10  )
    11  
    12  func TestGreatestExistingAncestor(t *testing.T) {
    13  	f := tempdir.NewTempDirFixture(t)
    14  
    15  	p, err := greatestExistingAncestor(f.Path())
    16  	assert.NoError(t, err)
    17  	assert.Equal(t, f.Path(), p)
    18  
    19  	p, err = greatestExistingAncestor(f.JoinPath("missing"))
    20  	assert.NoError(t, err)
    21  	assert.Equal(t, f.Path(), p)
    22  
    23  	missingTopLevel := "/missingDir/a/b/c"
    24  	if runtime.GOOS == "windows" {
    25  		missingTopLevel = "C:\\missingDir\\a\\b\\c"
    26  	}
    27  	_, err = greatestExistingAncestor(missingTopLevel)
    28  	assert.Contains(t, err.Error(), "cannot watch root directory")
    29  }