Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and fix post compat #426

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions compat/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Obv = require('obz')
exports.init = function (sbot) {
const post = Obv()
sbot.db.post = post
sbot.post = post
sbot.db.onMsgAdded((ev) => {
post.set(ev.kvt)
})
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ module.exports = [
require('ssb-box'),
require('ssb-box2'),
require('./compat/publish'),
require('./compat/post'),
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change, so be careful to make a new major version.

require('./migrate'),
]
13 changes: 13 additions & 0 deletions test/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const sbot = SecretStack({ appKey: caps.shs })
.use(require('../'))
.use(require('../compat/db'))
.use(require('../compat/history-stream'))
.use(require('../compat/post'))
.call(null, {
keys,
path: dir,
Expand Down Expand Up @@ -109,6 +110,18 @@ test('keys', (t) => {
t.end()
})

test('post', t=> {
sbot.post((msg)=> {
if (msg.value.content.text === 'post test') {
t.end()
}
})

sbot.publish({ type: 'test', text: 'post test'}, (err) => {
if (err) t.fail(err, 'failed publish for post')
})
})

test('teardown sbot', (t) => {
sbot.close(true, () => t.end())
})
2 changes: 1 addition & 1 deletion test/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdirp.sync(dir)

const keys = ssbKeys.loadOrCreateSync(path.join(dir, 'secret'))

const sbot = SecretStack({ appKey: caps.shs }).use(require('../')).call(null, {
const sbot = SecretStack({ appKey: caps.shs }).use(require('../')).use(require('../compat/post')).call(null, {
Copy link
Member

Choose a reason for hiding this comment

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

why is this one in here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because db.post.value is used further down in these tests

keys,
path: dir,
})
Expand Down