photoprism/pkg/rnd/name_test.go
Michael Mayer e21e462f00 Auth: Improve "auth add" and "client add" CLI commands #808 #3943
Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-13 16:27:05 +01:00

40 lines
701 B
Go

package rnd
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestName(t *testing.T) {
name := Name()
assert.NotEmpty(t, name)
assert.Equal(t, 1, strings.Count(name, " "))
for n := 0; n < 10; n++ {
s := Name()
t.Logf("Name %d: %s", n, s)
assert.NotEmpty(t, s)
assert.Equal(t, 1, strings.Count(s, " "))
}
}
func BenchmarkName(b *testing.B) {
for n := 0; n < b.N; n++ {
Name()
}
}
func TestNameN(t *testing.T) {
name := NameN(2)
assert.NotEmpty(t, name)
assert.Equal(t, 1, strings.Count(name, " "))
for n := 0; n < 10; n++ {
s := NameN(n + 1)
t.Logf("NameN %d: %s", n, s)
assert.NotEmpty(t, s)
assert.Equal(t, n, strings.Count(s, " "))
}
}