Skip to content

Commit

Permalink
Add a basic test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 26, 2024
1 parent 3506235 commit 8347b29
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ jobs:

- name: Run tests
timeout-minutes: 10
env:
DISCORD_BOT_TOKEN: ${{secrets.DISCORD_BOT_TOKEN}}
run: bundle exec bake test
20 changes: 20 additions & 0 deletions fixtures/async/discord/client_context.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
gem "rubocop"

gem "sus-fixtures-async-http"

gem "bake-test"
gem "bake-test-external"
end
4 changes: 4 additions & 0 deletions lib/async/discord/guilds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def each(&block)
def to_a
each.to_a
end

def empty?
self.value.empty?
end
end
end
end
14 changes: 14 additions & 0 deletions test/async/discord/client.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8347b29

Please # to comment.