golint: Lint pkg/namesgenerator
Also addded a couple more tests Updates #14756 Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
parent
49691393a9
commit
4ddc4a1cdf
2 changed files with 25 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package namesgenerator
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -12,6 +13,27 @@ func TestGenerateAwesomeNames(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// To be awesome, a container name must involve cool inventors, be easy to remember,
|
||||
// be at least mildly funny, and always be politically correct for enterprise adoption.
|
||||
func isAwesome(name string) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue