Files
immich/mobile/test/utils.dart
T
shenlong faab9e620d refactor: medium repository context helpers (#28311)
* refactor: medium repository context helpers

* test: add regress test for 26723

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2026-05-09 08:19:31 -05:00

23 lines
810 B
Dart

import 'dart:math';
import 'package:uuid/uuid.dart';
class TestUtils {
static final _random = Random();
static String uuid([String? id]) => id ?? const Uuid().v4();
static DateTime date([DateTime? date]) => date ?? DateTime.now();
static DateTime now() => DateTime.now();
static DateTime yesterday() => DateTime.now().subtract(const Duration(days: 1));
static DateTime tomorrow() => DateTime.now().add(const Duration(days: 1));
static T randElement<T>(List<T> list) => list[_random.nextInt(list.length)];
static int randInt([int? max]) => max != null ? _random.nextInt(max) : _random.nextInt(1 << 32);
static double randDouble([int? max, int? min]) {
final minValue = min ?? 0;
final maxValue = max ?? 1;
return minValue + _random.nextDouble() * (maxValue - minValue);
}
}