2019-12-11 16:55:18 +01:00
|
|
|
package entity
|
2019-05-16 04:03:55 +02:00
|
|
|
|
|
|
|
import (
|
2019-12-11 19:11:44 +01:00
|
|
|
"bytes"
|
2019-05-16 04:03:55 +02:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2019-12-11 19:11:44 +01:00
|
|
|
"github.com/sirupsen/logrus"
|
2019-12-27 05:18:52 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
2019-05-16 04:03:55 +02:00
|
|
|
)
|
|
|
|
|
2019-12-11 19:11:44 +01:00
|
|
|
var logBuffer bytes.Buffer
|
|
|
|
|
2019-05-16 04:03:55 +02:00
|
|
|
func TestMain(m *testing.M) {
|
2019-12-11 19:11:44 +01:00
|
|
|
log = logrus.StandardLogger()
|
|
|
|
log.Out = &logBuffer
|
|
|
|
log.SetLevel(logrus.DebugLevel)
|
2019-05-16 04:03:55 +02:00
|
|
|
code := m.Run()
|
|
|
|
os.Exit(code)
|
|
|
|
}
|
2019-12-27 05:18:52 +01:00
|
|
|
|
|
|
|
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')
|
|
|
|
}
|
|
|
|
}
|