-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ability to listen for notifications from postgres (#677)
* Adding ability to listen for notifications from postgres * Using a channel to ensure the listen spec is actually ran and checked * Update src/avram/database.cr Co-authored-by: Matthew McGarvey <[email protected]> Co-authored-by: Matthew McGarvey <[email protected]>
- Loading branch information
1 parent
02b786a
commit dcd0ee2
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "./spec_helper" | ||
|
||
describe Avram::Database do | ||
describe "listen" do | ||
it "yields the payload from a notify" do | ||
done = Channel(Nil).new | ||
TestDatabase.listen("dinner_time") do |notification| | ||
notification.channel.should eq "dinner_time" | ||
notification.payload.should eq "Tacos" | ||
done.send(nil) | ||
end | ||
|
||
TestDatabase.exec("SELECT pg_notify('dinner_time', 'Tacos')") | ||
done.receive | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters