photoprism/pkg/clean/error_test.go
Michael Mayer 91cc358fc5 Clean: Shorten error log sanitization function name #439 #3588
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-08-15 17:05:55 +02:00

26 lines
649 B
Go

package clean
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLogError(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
assert.Equal(t, "no error", Error(nil))
})
t.Run("Empty", func(t *testing.T) {
assert.Equal(t, "unknown error", Error(errors.New("")))
})
t.Run("Simple", func(t *testing.T) {
assert.Equal(t, "simple", Error(errors.New("simple")))
})
t.Run("Spaces", func(t *testing.T) {
assert.Equal(t, "'the quick brown fox'", Error(errors.New("the quick brown fox")))
})
t.Run("Invalid", func(t *testing.T) {
assert.Equal(t, "?", Error(errors.New("${https://<host>:<port>/<path>}")))
})
}