diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 50e9293..4bfeee3 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -32,6 +32,8 @@ jobs: - name: Run tests timeout-minutes: 5 + env: + DISCORD_BOT_TOKEN: ${{secrets.DISCORD_BOT_TOKEN}} run: bundle exec bake test - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test-external.yaml b/.github/workflows/test-external.yaml index 21898f5..80c0f85 100644 --- a/.github/workflows/test-external.yaml +++ b/.github/workflows/test-external.yaml @@ -33,4 +33,6 @@ jobs: - name: Run tests timeout-minutes: 10 + env: + DISCORD_BOT_TOKEN: ${{secrets.DISCORD_BOT_TOKEN}} run: bundle exec bake test:external diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0769a98..33be6a9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -47,4 +47,6 @@ jobs: - name: Run tests timeout-minutes: 10 + env: + DISCORD_BOT_TOKEN: ${{secrets.DISCORD_BOT_TOKEN}} run: bundle exec bake test diff --git a/fixtures/async/discord/client_context.rb b/fixtures/async/discord/client_context.rb new file mode 100644 index 0000000..9e2819f --- /dev/null +++ b/fixtures/async/discord/client_context.rb @@ -0,0 +1,20 @@ +require "async/discord/client" +require "sus/fixtures/async/reactor_context" + +module Async + module Discord + DISCORD_BOT_TOKEN = ENV.fetch("DISCORD_BOT_TOKEN") + + ClientContext = Sus::Shared("client context") do + include Sus::Fixtures::Async::ReactorContext + + def authenticated_client + client = Async::Discord::Client.open + + return client.authenticated(bot: DISCORD_BOT_TOKEN) + end + + let(:client) {authenticated_client} + end + end +end diff --git a/gems.rb b/gems.rb index 7fc4437..d8c9aff 100644 --- a/gems.rb +++ b/gems.rb @@ -22,4 +22,7 @@ gem "rubocop" gem "sus-fixtures-async-http" + + gem "bake-test" + gem "bake-test-external" end diff --git a/lib/async/discord/guilds.rb b/lib/async/discord/guilds.rb index b8f309b..3f67280 100644 --- a/lib/async/discord/guilds.rb +++ b/lib/async/discord/guilds.rb @@ -27,6 +27,10 @@ def each(&block) def to_a each.to_a end + + def empty? + self.value.empty? + end end end end diff --git a/test/async/discord/client.rb b/test/async/discord/client.rb new file mode 100644 index 0000000..d68dd66 --- /dev/null +++ b/test/async/discord/client.rb @@ -0,0 +1,14 @@ +require "async/discord/client_context" + +describe Async::Discord::Client do + include Async::Discord::ClientContext + + with "#guilds" do + it "can list guilds" do + guilds = client.guilds + + expect(guilds).to be_a(Async::Discord::Guilds) + expect(guilds).not.to be(:empty?) + end + end +end