github.com/tonyhb/nomad@v0.11.8/helper/uuid/uuid_test.go (about)

     1  package uuid
     2  
     3  import (
     4  	"regexp"
     5  	"testing"
     6  )
     7  
     8  func TestGenerate(t *testing.T) {
     9  	prev := Generate()
    10  	for i := 0; i < 100; i++ {
    11  		id := Generate()
    12  		if prev == id {
    13  			t.Fatalf("Should get a new ID!")
    14  		}
    15  
    16  		matched, err := regexp.MatchString(
    17  			"[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}", id)
    18  		if !matched || err != nil {
    19  			t.Fatalf("expected match %s %v %s", id, matched, err)
    20  		}
    21  	}
    22  }