github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/testutils/tempdir/temp_dir_fixture_test.go (about) 1 package tempdir 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestNestedDirs(t *testing.T) { 13 t.Run("inner", func(t *testing.T) { 14 f := NewTempDirFixture(t) 15 16 assert.Contains(t, f.Path(), "inner") 17 assert.Contains(t, f.Path(), "NestedDirs") 18 }) 19 } 20 21 func TestSanitizeForFilename(t *testing.T) { 22 for _, tc := range []struct { 23 input string 24 expectedOutput string 25 }{ 26 {"foobar", "foobar"}, 27 {"a>=b", "a__b"}, 28 {"1/2 power", "1_2_power"}, 29 {"cat:dog::mouse:cat", "cat_dog__mouse_cat"}, 30 } { 31 t.Run(fmt.Sprintf("escape %s", tc.input), func(t *testing.T) { 32 observed := SanitizeFileName(tc.input) 33 require.Equal(t, tc.expectedOutput, observed) 34 }) 35 } 36 }