Documentation
¶
Overview ¶
Package teledtest runs a real teled Telegram server in-process for tests.
New starts a fully-migrated server on a random local port backed by a throwaway PostgreSQL container, shut down automatically on test cleanup. It is the embeddable counterpart to gotd's tgtest: where tgtest makes you stub each RPC by hand, teledtest gives you the actual teled implementation (auth, DMs, media, bots, BotFather) to test a client against.
srv := teledtest.New(t)
err := srv.Run(ctx, nil, func(api *tg.Client) error {
_, err := api.HelpGetConfig(ctx)
return err
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// DC is the datacenter id clients should dial.
DC int
// Addr is the server's listen address.
Addr *net.TCPAddr
// Keys are the server public keys, for telegram.Options.PublicKeys.
Keys []telegram.PublicKey
// contains filtered or unexported fields
}
Server is a running in-process teled server with helpers to connect clients.
func New ¶
New starts a teled server backed by a throwaway PostgreSQL container and returns it. The server, database and connections are torn down on test cleanup. The test is skipped on hosts without container support.
func (*Server) Client ¶
Client builds a gotd client wired to this server. A nil storage uses a fresh in-memory session.