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

Add config to be able to index other fields #5

Closed
wants to merge 1 commit into from
Closed
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
64 changes: 59 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ test('generate fixture', (t) => {
return;
}

let keys

// for testing searching custom locations
function postComplicated() {
const sbot = SecretStack({appKey: caps.shs})
.use(require('ssb-db2'))
.call(null, {keys, path: dir});

sbot.db.create({
content: {
preferredName: {
set: 'potato'
},
legalName: {
set: 'asdf'
},
altNames: {
'john': 1,
'johan': -1,
}
}
}, (err) => {
if (err) t.fail(err)

sbot.db.onDrain('search', () => {
sbot.close(true, t.end);
});
})
}

generateFixture({
outputDir: dir,
seed: SEED,
Expand All @@ -31,10 +61,13 @@ test('generate fixture', (t) => {
}).then(() => {
t.true(fs.existsSync(oldLogPath), 'fixture was created');

const keys = ssbKeys.loadOrCreateSync(path.join(dir, 'secret'));
keys = ssbKeys.loadOrCreateSync(path.join(dir, 'secret'));
const sbot = SecretStack({appKey: caps.shs})
.use(require('ssb-db2'))
.call(null, {keys, path: dir, db2: {automigrate: true}});
.call(null, {keys, path: dir, db2: {
automigrate: true,
dangerouslyKillFlumeWhenMigrated: true
}});

pull(
sbot.db2migrate.progress(),
Expand All @@ -44,9 +77,30 @@ test('generate fixture', (t) => {
setTimeout(() => {
t.true(fs.existsSync(newLogPath), 'ssb-db2 migration completed');

sbot.db.onDrain('search', () => {
sbot.close(true, t.end);
});
sbot.db.create({
content: {
type: 'test',
preferredName: {
set: 'potato'
},
legalName: {
set: 'asdf'
},
altNames: {
'john': 1,
'johan': -1,
}
}
}, (err) => {
if (err) {
console.error('create failed', err)
t.fail(err)
}

sbot.db.onDrain('search', () => {
sbot.close(true, t.end);
});
})
}, 1000);
}),
);
Expand Down
Loading