summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthias Hecker <apoc@geekosphere.org>2015-06-14 20:05:45 +0200
committerMatthias Hecker <apoc@geekosphere.org>2015-06-14 20:05:45 +0200
commitdd06ceee0c26703a73acb225a6500579f38c8c3e (patch)
tree5d0ed8883a73f3ca0ec522a641a1f695178597d0 /test
parent075c7e031b3449ff026e51a2299f56df573ef688 (diff)
journal: even more tests
Diffstat (limited to 'test')
-rw-r--r--test/test_journal.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/test/test_journal.rb b/test/test_journal.rb
index 3f1ce766..9e8f0654 100644
--- a/test/test_journal.rb
+++ b/test/test_journal.rb
@@ -270,7 +270,7 @@ class JournalStoragePostgresTest < Test::Unit::TestCase
@storage.insert(JournalMessage.create('test.topic', {name: 'two'}))
@storage.insert(JournalMessage.create('test.topic', {name: 'three'}))
@storage.insert(JournalMessage.create('archived.topic', {name: 'four'},
- timestamp: Time.now - DAY*100))
+ timestamp: Time.now - DAY*100))
@storage.insert(JournalMessage.create('complex', {name: 'five', country: {
name: 'Italy'
}}))
@@ -278,15 +278,30 @@ class JournalStoragePostgresTest < Test::Unit::TestCase
name: 'Austria'
}}))
-
+ # query by topic
+ assert_equal(3, @storage.find(Query.define { topic 'test.*' }).length)
+ # query by payload
+ assert_equal(1, @storage.find(Query.define {
+ payload('country.name' => 'Austria') }).length)
+ # query by timestamp range
+ assert_equal(1, @storage.find(Query.define {
+ timestamp(from: Time.now - DAY*150, to: Time.now - DAY*50) }).length)
+
+ # count with query
+ assert_equal(2, @storage.count(Query.define { topic('complex') }))
+ assert_equal(6, @storage.count)
+ @storage.remove(Query.define { topic('archived.*') })
+ assert_equal(5, @storage.count)
+ @storage.remove
+ assert_equal(0, @storage.count)
end
def test_journal
- received = []
# this journal persists messages in the test storage:
journal = JournalBroker.new(storage: @storage)
-
-
+ journal.publish 'log.irc', action: 'message'
+ sleep 0.1
+ assert_equal(1, journal.count)
end
end