diff --git a/randsmust/strings_test.go b/randsmust/strings_test.go index 508bbaf..9a48281 100644 --- a/randsmust/strings_test.go +++ b/randsmust/strings_test.go @@ -547,10 +547,13 @@ func TestUUIDv7(t *testing.T) { timestampBytes := int64(b[0])<<40 | int64(b[1])<<32 | int64(b[2])<<24 | int64(b[3])<<16 | int64(b[4])<<8 | int64(b[5]) - // Verify timestamp is within 100 milliseconds of current time + // Verify timestamp is within 10 seconds of current time. This is a + // sanity check to ensure the UUID is not too far off from the current + // time, while allowing tests to pass on super slow machines. tsTime := time.UnixMilli(timestampBytes) - require.WithinDuration(t, time.Now(), tsTime, 100*time.Millisecond, - "timestamp is not within 100 milliseconds of current time") + require.WithinDuration(t, time.Now(), tsTime, 10*time.Second, + "timestamp is not within 10 seconds of current time", + ) // After the first UUID, verify that UUIDs are monotonically increasing if i > 0 && timestampBytes < lastTimestampBytes { diff --git a/strings_test.go b/strings_test.go index d7eefe6..4d9b36b 100644 --- a/strings_test.go +++ b/strings_test.go @@ -680,10 +680,12 @@ func TestUUIDv7(t *testing.T) { timestampBytes := int64(b[0])<<40 | int64(b[1])<<32 | int64(b[2])<<24 | int64(b[3])<<16 | int64(b[4])<<8 | int64(b[5]) - // Verify timestamp is within 100 milliseconds of current time + // Verify timestamp is within 10 seconds of current time. This is a + // sanity check to ensure the UUID is not too far off from the current + // time, while allowing tests to pass on super slow machines. tsTime := time.UnixMilli(timestampBytes) - require.WithinDuration(t, time.Now(), tsTime, 100*time.Millisecond, - "timestamp is not within 100 milliseconds of current time", + require.WithinDuration(t, time.Now(), tsTime, 10*time.Second, + "timestamp is not within 10 seconds of current time", ) // After the first UUID, verify that UUIDs are monotonically increasing diff --git a/uuid/version_7_test.go b/uuid/version_7_test.go index e0af351..a095f98 100644 --- a/uuid/version_7_test.go +++ b/uuid/version_7_test.go @@ -43,10 +43,13 @@ func TestUUIDv7(t *testing.T) { int64(got[2])<<24 | int64(got[3])<<16 | int64(got[4])<<8 | int64(got[5]) - // Verify timestamp is within 100 milliseconds of current time. + // Verify timestamp is within 10 seconds of current time. This is a + // sanity check to ensure the UUID is not too far off from the current + // time, while allowing tests to pass on super slow machines. tsTime := time.UnixMilli(timestampBytes) - require.WithinDuration(t, time.Now(), tsTime, 100*time.Millisecond, - "timestamp is not within 100 milliseconds of current time") + require.WithinDuration(t, time.Now(), tsTime, 10*time.Second, + "timestamp is not within 10 seconds of current time", + ) // After the first UUID, verify that UUIDs are monotonically increasing if i > 0 && timestampBytes < lastTimestampBytes {