package tezos-event-logging-test-helpers

  1. Overview
  2. Docs
Legend:
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
type t
val uri_scheme : string
val configure : Uri.t -> t Tezos_error_monad.Error_monad.tzresult Lwt.t
val should_handle : ?section:Tezos_event_logging__Internal_event.Section.t -> t -> 'a Tezos_event_logging__Internal_event.event_definition -> bool
val handle : t -> 'a Tezos_event_logging__Internal_event.event_definition -> ?section:Tezos_event_logging__Internal_event.Section.t -> 'a -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t
val close : t -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t
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 = {
  1. level : Tezos_event_logging.Internal_event.Level.t;
  2. section : Tezos_event_logging.Internal_event.Section.t option;
  3. name : string;
  4. message : string;
  5. json : Data_encoding.json;
}
module Pattern : sig ... end

Describes an event pattern to search for in the sink.

type pattern = Pattern.t
val assert_has_event : string -> ?filter:filter -> ?strict:bool -> pattern -> unit

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).

val assert_has_events : string -> ?filter:filter -> ?strict:bool -> pattern list -> unit

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).

val clear_events : unit -> unit

Clears recorded events, typically called in the initialization of each test.

val is_activated : unit -> bool

Returns true if this sink has been activated

val pp_state : ?filter:filter -> unit -> unit

Pretty prints the list of recorded events

val pp_events_json : Stdlib.Format.formatter -> event list -> unit
val get_events : ?filter:filter -> unit -> event list
val testable_level : Tezos_event_logging.Internal_event.Level.t Octez_alcotezt.Alcotest.testable
val testable_section : Tezos_event_logging.Internal_event.Section.t Octez_alcotezt.Alcotest.testable
OCaml

Innovation. Community. Security.