Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ function abstractPersistence (opts) {
throw new Error('no instance')
}

async function matchRetainedWithPattern (t, pattern) {
async function matchRetainedWithPattern (t, pattern, opts) {
const prInstance = await persistence(t)
const packet = await storeRetainedPacket(prInstance)
const packet = await storeRetainedPacket(prInstance, opts)
let stream
if (Array.isArray(pattern)) {
stream = prInstance.createRetainedStreamCombi(pattern)
Expand Down Expand Up @@ -122,11 +122,31 @@ function abstractPersistence (opts) {
await matchRetainedWithPattern(t, 'hello/+')
})

test('look up retained messages with a + as first element', async t => {
t.plan(1)
await matchRetainedWithPattern(t, '+/world')
})

test('look up retained messages with +/#', async t => {
t.plan(1)
await matchRetainedWithPattern(t, '+/#')
})

test('look up retained messages with a + and # pattern with some in between', async t => {
t.plan(1)
await matchRetainedWithPattern(t, 'hello/+/world/#', { topic: 'hello/there/world/creatures' })
})
Comment on lines +125 to +138
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this also test passing an array of patterns?


test('look up retained messages with multiple patterns', async t => {
t.plan(1)
await matchRetainedWithPattern(t, ['hello/+', 'other/hello'])
})

test('look up retained messages with multiple wildcard patterns', async t => {
t.plan(1)
await matchRetainedWithPattern(t, ['hello/+', 'hel/#', 'hello/world/there/+'])
})

test('store multiple retained messages in order', async (t) => {
t.plan(1000)
const prInstance = await persistence(t)
Expand Down