photoprism/internal/entity/entity_test.go
Michael Mayer 366c70d992 Optimize performance and data structures
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2019-12-27 05:18:52 +01:00

35 lines
514 B
Go

package entity
import (
"bytes"
"os"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
var logBuffer bytes.Buffer
func TestMain(m *testing.M) {
log = logrus.StandardLogger()
log.Out = &logBuffer
log.SetLevel(logrus.DebugLevel)
code := m.Run()
os.Exit(code)
}
func TestID(t *testing.T) {
for n := 0; n < 5; n++ {
uuid := ID('x')
t.Logf("id: %s", uuid)
assert.Equal(t, len(uuid), 17)
}
}
func BenchmarkID(b *testing.B) {
for n := 0; n < b.N; n++ {
ID('x')
}
}