github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/pkg/namesgenerator/names-generator_test.go (about)

     1  package 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  }