abetomo
null+****@clear*****
Thu Sep 21 10:40:31 JST 2017
abetomo 2017-09-21 10:40:31 +0900 (Thu, 21 Sep 2017) New Revision: 645e9f6ddad2cc516b9a662c9b7728994e1954c4 https://github.com/nroonga/nroonga/commit/645e9f6ddad2cc516b9a662c9b7728994e1954c4 Merged a6488cf: Merge pull request #27 from abetomo/add_asynchronous_method_test Message: Add command() test Modified files: test/database.test.js Modified: test/database.test.js (+95 -41) =================================================================== --- test/database.test.js 2017-09-20 15:52:15 +0900 (2702647) +++ test/database.test.js 2017-09-21 10:40:31 +0900 (46a6660) @@ -111,6 +111,24 @@ describe('database with data stored', () => { let db = null const tempdir = path.join('test', 'tmp') const databaseName = `tempdb-${process.pid}-${(new Date()).valueOf()}` + const expectedDump = `table_create Site TABLE_HASH_KEY ShortText +column_create Site title COLUMN_SCALAR ShortText + +table_create Terms TABLE_PAT_KEY ShortText \ +--default_tokenizer TokenBigram --normalizer NormalizerAuto + +load --table Site +[ +["_key","title"], +["http://groonga.org/",\ +"groonga - An open-source fulltext search engine and column store"], +["http://groonga.rubyforge.org/",\ +"Fulltext search by Ruby with groonga - Ranguba"], +["http://mroonga.github.com/",\ +"Groonga storage engine - Fast fulltext search on MySQL"] +] + +column_create Terms entry_title COLUMN_INDEX|WITH_POSITION Site title` beforeEach(() => { if (!fs.existsSync(tempdir)) fs.mkdirSync(tempdir) @@ -152,58 +170,94 @@ describe('database with data stored', () => { fs.removeSync(tempdir) }) - it('should select records', () => { - const matched = db.commandSync('select', {table: 'Site'}) - expect(matched[0][0][0]).to.equal(3) - }) + describe('#commandSync', () => { + it('should select records', () => { + const matched = db.commandSync('select', {table: 'Site'}) + expect(matched[0][0][0]).to.equal(3) + }) - it('should select records ignoring the null valued option', () => { - const matched = db.commandSync('select', { - table: 'Site', - query: null + it('should select records ignoring the null valued option', () => { + const matched = db.commandSync('select', { + table: 'Site', + query: null + }) + expect(matched[0][0][0]).to.equal(3) }) - expect(matched[0][0][0]).to.equal(3) - }) - it('should search by query', () => { - const matched = db.commandSync('select', { - table: 'Site', - match_columns: 'title', - query: 'ruby' + it('should search by query', () => { + const matched = db.commandSync('select', { + table: 'Site', + match_columns: 'title', + query: 'ruby' + }) + expect(matched[0][0][0]).to.equal(1) }) - expect(matched[0][0][0]).to.equal(1) - }) - it('should search by query including space', () => { - const matched = db.commandSync('select', { - table: 'Site', - match_columns: 'title', - query: 'search ranguba' + it('should search by query including space', () => { + const matched = db.commandSync('select', { + table: 'Site', + match_columns: 'title', + query: 'search ranguba' + }) + expect(matched[0][0][0]).to.equal(1) + }) + + it('should dump all records', () => { + const result = db.commandSync('dump', {tables: 'Site'}) + expect(result).to.equal(expectedDump) }) - expect(matched[0][0][0]).to.equal(1) }) - it('should dump all records', () => { - const expectedDump = `table_create Site TABLE_HASH_KEY ShortText -column_create Site title COLUMN_SCALAR ShortText + describe('#command', () => { + it('should select records', done => { + db.command('select', {table: 'Site'}, (err, data) => { + expect(err).to.be.null + expect(data[0][0][0]).to.equal(3) + done() + }) + }) -table_create Terms TABLE_PAT_KEY ShortText \ ---default_tokenizer TokenBigram --normalizer NormalizerAuto + it('should select records ignoring the null valued option', done => { + db.command('select', { + table: 'Site', + query: null + }, (err, data) => { + expect(err).to.be.null + expect(data[0][0][0]).to.equal(3) + done() + }) + }) -load --table Site -[ -["_key","title"], -["http://groonga.org/",\ -"groonga - An open-source fulltext search engine and column store"], -["http://groonga.rubyforge.org/",\ -"Fulltext search by Ruby with groonga - Ranguba"], -["http://mroonga.github.com/",\ -"Groonga storage engine - Fast fulltext search on MySQL"] -] + it('should search by query', done => { + db.command('select', { + table: 'Site', + match_columns: 'title', + query: 'ruby' + }, (err, data) => { + expect(err).to.be.null + expect(data[0][0][0]).to.equal(1) + done() + }) + }) -column_create Terms entry_title COLUMN_INDEX|WITH_POSITION Site title` + it('should search by query including space', done => { + db.command('select', { + table: 'Site', + match_columns: 'title', + query: 'search ranguba' + }, (err, data) => { + expect(err).to.be.null + expect(data[0][0][0]).to.equal(1) + done() + }) + }) - const result = db.commandSync('dump', {tables: 'Site'}) - expect(result).to.equal(expectedDump) + it('should dump all records', done => { + db.command('dump', {tables: 'Site'}, (err, data) => { + expect(err).to.be.null + expect(data).to.equal(expectedDump) + done() + }) + }) }) }) -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170921/b30b063a/attachment-0001.htm