createTestClient function

TestClient createTestClient({
  1. Map<String, Object?> values = const {},
  2. Duration? timeout,
  3. ConfigDirectorLogger? logger,
})

Creates a TestClient holding a real ConfigDirectorClient that serves values without a network connection.

values are the configs the client serves once initialized, keyed by config key. The config type follows from each value's type: a bool is a boolean config, an int an integer config, a double a float config, a String a string config, and a Map with String keys or a List a JSON config. A null value, a non-finite number, a blank key, or a value of any other type throws a ConfigDirectorValidationException.

timeout is the client's connection timeout, which bounds how long a held initialize or updateContext waits. It defaults to the SDK's production timeout. logger is the logger the client uses, defaulting to the SDK's console logger. Since the test client sends no telemetry, every tracked event that is not recorded as it was tracked logs a warning, rather than each cause once per telemetry batch.

The client starts uninitialized, like a production client, so the code under test can own the call to initialize. With nothing held or failed, initialize completes at once with the client ready.

Implementation

TestClient createTestClient({
  Map<String, Object?> values = const {},
  Duration? timeout,
  ConfigDirectorLogger? logger,
}) => TestClient._(
  InMemoryConnection(values: values, timeout: timeout, logger: logger),
);