photoprism/pkg/clean/header_test.go
Michael Mayer 239708f00f Config: Add options to configure CORS origin, headers and methods #3931
Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-16 12:14:06 +01:00

35 lines
920 B
Go

package clean
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHeader(t *testing.T) {
t.Run("Ok", func(t *testing.T) {
expected := "https://docs.photoprism.app/getting-started/config-options/#file-converters"
result := Header(expected)
assert.Equal(t, expected, result)
})
t.Run("Tabs", func(t *testing.T) {
result := Header("https://..docs.photoprism.app/gettin\\g-started/config-options/\tfile-converters")
assert.Equal(t, "https://..docs.photoprism.app/gettin\\g-started/config-options/file-converters", result)
})
t.Run("Emoji", func(t *testing.T) {
result := Header("Hello 👍")
assert.Equal(t, "Hello ", result)
})
}
func BenchmarkHeader(b *testing.B) {
for n := 0; n < b.N; n++ {
Header("https://..docs.photoprism.app/gettin\\g-started/config-options/\tfile-converters")
}
}
func BenchmarkHeaderEmpty(b *testing.B) {
for n := 0; n < b.N; n++ {
Header("")
}
}