-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you test bots with this library? #250
Comments
The If you do not want to supply a token in the test environment you have options. You could run the tests with These aren't nostrum-specific constructs, they're provided at the language level. That said I think it would probably be prudent to include a reminder in the nostrum docs somewhere because this question has cropped up in the past, so thanks for that! |
Just wanted to add my thoughts on this after myself and @jchristgit both mentioned it inside #309 where it is slightly off-topic. My idea is to implement a testing bot for running #doctest_helpers.ex
defmodule DoctestHelpers do
def doctest_server_id()
System.get_env("DEV_SERVER_ID")
end
end #nostrum.api.ex
import DoctestHelpers
@doc """
Gets a list of guild channels.
## Examples
iex> Nostrum.Api.get_guild_channels(doctest_server_id)
{:ok, [%Nostrum.Struct.Channel{guild_id: ^doctest_server_id} | _]}
"""
@doc """
Creates a channel for a guild.
## Examples
iex> Nostrum.Api.create_guild_channel(doctest_server_id, name: "elixir-nostrum", topic: "craig's domain")
{:ok, %Nostrum.Struct.Channel{guild_id: ^doctest_server_id}}
""" This has the downside of making the documentation less readable. So a solution that covers that would be to replace all instances of these helpers with a dummy value when creating the documentation. This is a bit of a pain, but I believe would be worth it, if it gives you functional doctests without all the setup/teardown/hardcoded values. |
I can't seem to find anything in the documentation to configure nostrum to NOT spin up and connect to discord when running tests for the code. I tried dev: true. but it seemed to do nothing.
I do not want to be using a real discord token in a test environment.
The text was updated successfully, but these errors were encountered: