/helper/uuid/uuid_test.go
https://gitlab.com/sthysel/vault · Go · 22 lines · 19 code · 3 blank · 0 comment · 6 complexity · 055012057e9def4280e3f4d8a5a14c21 MD5 · raw file
- package uuid
- import (
- "regexp"
- "testing"
- )
- func TestGenerateUUID(t *testing.T) {
- prev := GenerateUUID()
- for i := 0; i < 100; i++ {
- id := GenerateUUID()
- 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)
- }
- }
- }