Library
Module
Module type
Parameter
Class
Class type
A mock event sink that records handled events for verifying test expectations.
include Tezos_event_logging.Internal_event.SINK
A sink can store any required state, e.g. a database handle, in a value of the t
type see configure
.
val configure : Uri.t -> t Tezos_error_monad.Error_monad.tzresult Lwt.t
When a registered sink is activated the configure
function is called to initialize it. The parameters should be encoded or obtained from the URI (the scheme of the URI is already uri_scheme
).
val handle :
t ->
'a Tezos_event_logging.Internal_event.event_definition ->
?section:Tezos_event_logging.Internal_event.Section.t ->
(unit -> 'a) ->
unit Tezos_error_monad.Error_monad.tzresult Lwt.t
A sink's main function is to handle
incoming events from the code base.
val close : t -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t
A function to be called on graceful termination of processes (e.g. to flush file-descriptors, etc.).
type filter = Tezos_event_logging.Internal_event.Section.t option
A filter
can be applied when asserting the contents of the sink. This restricts assertions to events from a specific section or to those that have no section. The value filter
has the following meaning:
filter = None
: only keep events that have no section.filter = Some s
: only keep events with section s
.Note that the filter is always passed as an optional parameter. It can be omited to keep all events.
type event = {
level : Tezos_event_logging.Internal_event.Level.t;
section : Tezos_event_logging.Internal_event.Section.t option;
name : string;
message : string;
json : Data_encoding.json;
}
module Pattern : sig ... end
Describes an event pattern to search for in the sink.
type pattern = Pattern.t
assert_has_event str filter strict e
asserts that Mock_sink has recorded an event e
, and fails with the assertion message str
if not. If filter
is set, only the events whose section is filter
are searched. If strict
is set, then e
must be the only event recorded (subject to filter
).
assert_has_events str filter strict es
asserts that Mock_sink has recorded the list of events es
, and fails with the assertion message str
if not. If filter
is set, only the events whose section is filter
are searched. If strict
is set, then es
must be the only events recorded (subject to filter
).
Clears recorded events, typically called in the initialization of each test.
val pp_state : ?filter:filter -> unit -> unit
Pretty prints the list of recorded events
val pp_events_json : Format.formatter -> event list -> unit
val testable_event : event Alcotest.testable
val testable_level :
Tezos_event_logging.Internal_event.Level.t Alcotest.testable
val testable_section :
Tezos_event_logging.Internal_event.Section.t Alcotest.testable