MockTelemetryBackend

Keeps everything it is given, for tests that want to check what robot code logged.

val clock = TestTimeSource()
val registry = TelemetryRegistry(clock)
val mock = MockTelemetryBackend().also(registry::register)

registry.table("Drive").log("left", 1.5)

assertEquals(listOf(1.5), mock.valuesAt("/Drive/left"))

Arrays and lists are copied when they are logged, so changing one afterwards doesn't change what the backend recorded. A struct is recorded as the object that was logged, so tests can compare it with ==. It is safe to log from several threads. The inspection methods return copies, which can be stale if logging is still running.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
data class Record(val path: String, val value: Any?, val timestampMicros: Long)

One logged value.

Properties

Link copied to clipboard

Whether close has been called.

Link copied to clipboard

The paths that have an entry, in the order they were created.

Link copied to clipboard

Every value logged, in the order the backend received them.

Functions

Link copied to clipboard
fun clear()

Forgets every logged value, keeping the entries.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun entry(path: String, type: TelemetryType, properties: Map<String, Any> = emptyMap()): TelemetryEntry

Returns the entry for path, creating it if this backend hasn't seen the path.

Link copied to clipboard

The properties path was created with, or an empty map if nothing has created it.

Link copied to clipboard

The timestamps of the values logged to path, oldest first, in microseconds.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

The type path was created with, or null if nothing has created it.

Link copied to clipboard
fun valuesAt(path: String): List<Any?>

The values logged to path, oldest first. Arrays are BooleanArray, DoubleArray and so on.