open-nomad/helper/uuid/uuid_test.go
Michael Schurter a66c53d45a Remove structs import from api
Goes a step further and removes structs import from api's tests as well
by moving GenerateUUID to its own package.
2017-09-29 10:36:08 -07:00

23 lines
412 B
Go

package uuid
import (
"regexp"
"testing"
)
func TestGenerate(t *testing.T) {
prev := Generate()
for i := 0; i < 100; i++ {
id := Generate()
if prev == id {
t.Fatalf("Should get a new ID!")
}
matched, err := regexp.MatchString(
"[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}", id)
if !matched || err != nil {
t.Fatalf("expected match %s %v %s", id, matched, err)
}
}
}