2013-12-23 23:45:18 +00:00
|
|
|
package namesgenerator
|
|
|
|
|
|
|
|
import (
|
2015-07-21 14:06:31 +00:00
|
|
|
"strings"
|
2013-12-23 23:45:18 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2015-07-21 14:06:31 +00:00
|
|
|
func TestNameFormat(t *testing.T) {
|
|
|
|
name := GetRandomName(0)
|
|
|
|
if !strings.Contains(name, "_") {
|
|
|
|
t.Fatalf("Generated name does not contain an underscore")
|
|
|
|
}
|
|
|
|
if strings.ContainsAny(name, "0123456789") {
|
|
|
|
t.Fatalf("Generated name contains numbers!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNameRetries(t *testing.T) {
|
|
|
|
name := GetRandomName(1)
|
|
|
|
if !strings.Contains(name, "_") {
|
|
|
|
t.Fatalf("Generated name does not contain an underscore")
|
|
|
|
}
|
|
|
|
if !strings.ContainsAny(name, "0123456789") {
|
|
|
|
t.Fatalf("Generated name doesn't contain a number")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|