telega/testing/context
Context and config builders for testing.
Provides functions to create bot.Context, config.Config,
and bot.SessionSettings with sensible test defaults.
import telega/testing/context
import telega/testing/factory
let ctx = context.context(session: MySession(count: 0))
let cfg = context.config()
Values
pub fn catch_handler() -> fn(bot.Context(session, error), error) -> Result(
Nil,
error,
)
Creates a no-op catch handler.
pub fn config_with_client(
client: client.TelegramClient,
) -> @internal Config
Creates a test Config with the given Telegram client.
Use this with mock.message_client() to get a config that returns valid API responses.
pub fn context(
session session: session,
) -> bot.Context(session, error)
Creates a Context with the given session and default update/config.
pub fn context_with(
session session: session,
update update: update.Update,
) -> bot.Context(session, error)
Creates a Context with the given session and update.
pub fn context_with_all(
session session: session,
update update: update.Update,
key key: String,
bot_info bot_info: types.User,
) -> bot.Context(session, error)
Creates a Context with full customization.
pub fn session_settings(
default default: fn() -> session,
) -> bot.SessionSettings(session, error)
Creates SessionSettings with a no-op persist and get returning None.
pub fn session_settings_with(
default default: fn() -> session,
initial initial: session,
) -> bot.SessionSettings(session, error)
Creates SessionSettings where get returns Some(initial).