github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/pkg/namesgenerator/names-generator_test.go (about)

     1  package namesgenerator // import "github.com/demonoid81/moby/pkg/namesgenerator"
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  )
     7  
     8  func TestNameFormat(t *testing.T) {
     9  	name := GetRandomName(0)
    10  	if !strings.Contains(name, "_") {
    11  		t.Fatalf("Generated name does not contain an underscore")
    12  	}
    13  	if strings.ContainsAny(name, "0123456789") {
    14  		t.Fatalf("Generated name contains numbers!")
    15  	}
    16  }
    17  
    18  func TestNameRetries(t *testing.T) {
    19  	name := GetRandomName(1)
    20  	if !strings.Contains(name, "_") {
    21  		t.Fatalf("Generated name does not contain an underscore")
    22  	}
    23  	if !strings.ContainsAny(name, "0123456789") {
    24  		t.Fatalf("Generated name doesn't contain a number")
    25  	}
    26  
    27  }