Expect objectid as a data category rather than a builtin
This commit is contained in:
+1
-2
@@ -15,7 +15,6 @@ func TestBuiltinIDGenerators(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"uuid v7", `{"format":"{uuid()}"}`, regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)},
|
{"uuid v7", `{"format":"{uuid()}"}`, regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)},
|
||||||
{"ulid", `{"format":"{ulid()}"}`, regexp.MustCompile(`^[0-7][0-9A-HJKMNP-TV-Z]{25}$`)},
|
{"ulid", `{"format":"{ulid()}"}`, regexp.MustCompile(`^[0-7][0-9A-HJKMNP-TV-Z]{25}$`)},
|
||||||
{"objectid", `{"format":"{objectid()}"}`, regexp.MustCompile(`^[0-9a-f]{24}$`)},
|
|
||||||
{"nanoid", `{"format":"{nanoid(21)}"}`, regexp.MustCompile(`^[A-Za-z0-9_-]{21}$`)},
|
{"nanoid", `{"format":"{nanoid(21)}"}`, regexp.MustCompile(`^[A-Za-z0-9_-]{21}$`)},
|
||||||
{"hex", `{"format":"{hex(16)}"}`, regexp.MustCompile(`^[0-9a-f]{16}$`)},
|
{"hex", `{"format":"{hex(16)}"}`, regexp.MustCompile(`^[0-9a-f]{16}$`)},
|
||||||
}
|
}
|
||||||
@@ -39,7 +38,7 @@ func TestBuiltinIDGenerators(t *testing.T) {
|
|||||||
// generator draws only from the seeded rng, so same seed -> same value.
|
// generator draws only from the seeded rng, so same seed -> same value.
|
||||||
func TestBuiltinGeneratorsReproducible(t *testing.T) {
|
func TestBuiltinGeneratorsReproducible(t *testing.T) {
|
||||||
for _, tmpl := range []string{
|
for _, tmpl := range []string{
|
||||||
`{"format":"{uuid()}"}`, `{"format":"{ulid()}"}`, `{"format":"{objectid()}"}`,
|
`{"format":"{uuid()}"}`, `{"format":"{ulid()}"}`,
|
||||||
`{"format":"{nanoid(12)}"}`, `{"format":"{int(1,1000000)}"}`,
|
`{"format":"{nanoid(12)}"}`, `{"format":"{int(1,1000000)}"}`,
|
||||||
`{"format":"{float(0,1,6)}"}`, `{"format":"{base64(12)}"}`, `{"format":"{iban(SE)}"}`,
|
`{"format":"{float(0,1,6)}"}`, `{"format":"{base64(12)}"}`, `{"format":"{iban(SE)}"}`,
|
||||||
} {
|
} {
|
||||||
|
|||||||
@@ -72,7 +72,11 @@ func TestShippedMiscCategories(t *testing.T) {
|
|||||||
f := newFakes(t, "data/misc", WithSeed(1))
|
f := newFakes(t, "data/misc", WithSeed(1))
|
||||||
v4 := regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)
|
v4 := regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)
|
||||||
mac := regexp.MustCompile(`^([0-9a-f]{2}:){5}[0-9a-f]{2}$`)
|
mac := regexp.MustCompile(`^([0-9a-f]{2}:){5}[0-9a-f]{2}$`)
|
||||||
|
objectid := regexp.MustCompile(`^[0-9a-f]{24}$`)
|
||||||
for i := 0; i < 200; i++ {
|
for i := 0; i < 200; i++ {
|
||||||
|
if v := fake(t, f, "objectid"); !objectid.MatchString(v) {
|
||||||
|
t.Fatalf("misc objectid %q is not 24 hex chars", v)
|
||||||
|
}
|
||||||
if v := fake(t, f, "uuid"); !v4.MatchString(v) {
|
if v := fake(t, f, "uuid"); !v4.MatchString(v) {
|
||||||
t.Fatalf("misc uuid %q is not a valid v4", v)
|
t.Fatalf("misc uuid %q is not a valid v4", v)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user