package upload import ( "testing" "github.com/stretchr/testify/assert" ) func Test_SanitizeFileName(t *testing.T) { tests := []struct { name string expected string }{ { name: "foo", expected: "foo", }, { name: "foo bar", expected: "foo.bar", }, { name: ".foo", expected: "default.foo", }, { name: "Foo bar", expected: "Foo.bar", }, { name: "Hello, दुनिया", expected: "default.Hello", }, { name: "this+has+plusses.jpg", expected: "this+has+plusses.jpg", }, { name: "this@has@at@signs.jpg", expected: "this@has@at@signs.jpg", }, { name: "façade.exposé", expected: "facade.expose", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { assert.Equal(t, tt.expected, sanitizeFileName(tt.name)) }) } }