Set up CI, fix updating archive meta documents #10

Merged
raucao merged 10 commits from dev/testing into master 2022-08-12 15:04:54 +00:00
Showing only changes of commit e663a46242 - Show all commits

View File

@ -1,5 +1,5 @@
const expect = require('chai').expect;
const sinon = require("sinon");
const sandbox = require("sinon").createSandbox();
const ChatMessages = require('../dist/build');
const rsClient = {
@ -64,6 +64,46 @@ describe('ChatMessages', function () {
expect(archive.next).to.be.an('undefined');
});
});
describe('#_updateArchiveMetaDocument', function () {
describe('meta up to date', function () {
before(function() {
sandbox.stub(archive.client, 'getObject').withArgs(archive.metaPath)
.returns({
'@id': `chat-messages/irc.libera.chat/channels/kosmos/meta`,
'@type': 'ChatChannelMeta',
first: '2021/01/01', last: '2022/08/11'
})
sandbox.stub(archive.client, 'storeObject');
});
it('does not store a new archive', async function () {
await archive._updateArchiveMetaDocument();
sandbox.assert.notCalled(archive.client.storeObject);
});
after(function() { sandbox.restore() });
});
describe('meta needs updating', function () {
before(function() {
sandbox.stub(archive.client, 'getObject').withArgs(archive.metaPath)
.returns({
'@id': `chat-messages/irc.libera.chat/channels/kosmos/meta`,
'@type': 'ChatChannelMeta',
first: '2021/01/01', last: '2022/08/10'
})
sandbox.stub(archive.client, 'storeObject');
});
it('stores a new archive', async function () {
await archive._updateArchiveMetaDocument();
sandbox.assert.calledOnce(archive.client.storeObject);
});
after(function() { sandbox.restore() });
});
});
});
});