paths_test.go 683 B

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