abetomo
null+****@clear*****
Mon Sep 11 17:08:56 JST 2017
abetomo 2017-09-11 17:08:56 +0900 (Mon, 11 Sep 2017) New Revision: 659b6f9ac941be0c24d74b420e68fb58dcb06142 https://github.com/nroonga/nroonga/commit/659b6f9ac941be0c24d74b420e68fb58dcb06142 Merged 6c58e33: Merge pull request #20 from abetomo/change_using_chai_with_test Message: Change to test using chai.expect Removed files: test/database.test.coffee Modified files: package.json Modified: package.json (+1 -3) =================================================================== --- package.json 2017-09-11 17:06:14 +0900 (c91760c) +++ package.json 2017-09-11 17:08:56 +0900 (d8efd3d) @@ -18,10 +18,8 @@ "url": "http://github.com/nroonga/nroonga/issues" }, "devDependencies": { - "coffee-script": "", "chai": "", "mocha": "", - "should": "", "standard": "^10.0.3" }, "dependencies": { @@ -31,7 +29,7 @@ "install": "node-gyp rebuild", "lint": "standard", "test": "npm run lint && npm run unit", - "unit": "mocha --reporter list -r should --compilers coffee:coffee-script/register" + "unit": "mocha --reporter list" }, "main": "./lib/nroonga", "engines": { Deleted: test/database.test.coffee (+0 -166) 100644 =================================================================== --- test/database.test.coffee 2017-09-11 17:06:14 +0900 (76c94c5) +++ /dev/null @@ -1,166 +0,0 @@ -nroonga = require('../lib/nroonga') -fs = require('fs') -should = require('should') - -temporaryDatabase = (callback) -> - tempdir = 'test/tmp' - fs.mkdir tempdir, -> - databaseName = "tempdb-#{process.pid}-#{(new Date()).valueOf()}" - db = new nroonga.Database(tempdir + '/' + databaseName) - - try - callback(db) - finally - db.close() - fs.readdir tempdir, (err, files) -> - throw err if err? - re = RegExp('^' + databaseName) - for file in files when file.match(re) - fs.unlinkSync(tempdir + '/' + file) - -withTestDatabase = (callback) -> - temporaryDatabase (db) -> - db.commandSync 'table_create', - name: 'Site' - flags: 'TABLE_HASH_KEY' - key_type: 'ShortText' - db.commandSync 'column_create', - table: 'Site' - name: 'title' - flags: 'COLUMN_SCALAR' - type: 'ShortText' - - db.commandSync 'table_create', - name: 'Terms' - flags: 'TABLE_PAT_KEY|KEY_NORMALIZE' - key_type: 'ShortText' - default_tokenizer: 'TokenBigram' - db.commandSync 'column_create', - table: 'Terms' - name: 'entry_title' - flags: 'COLUMN_INDEX|WITH_POSITION' - type: 'Site' - source: 'title' - - db.commandSync 'load', - table: 'Site' - values: JSON.stringify [ - _key: "http://groonga.org/" - title: "groonga - An open-source fulltext search engine and column store" - , - _key: "http://groonga.rubyforge.org/" - title: "Fulltext search by Ruby with groonga - Ranguba" - , - _key: "http://mroonga.github.com/" - title: "Groonga storage engine - Fast fulltext search on MySQL" - ] - - callback(db) - -describe 'nroonga.Database', -> - db = null - beforeEach -> - db = new nroonga.Database() - - describe '#commandSync', -> - it 'should return groonga results', -> - status = db.commandSync('status') - should.exist(status.version) - - describe '#command', -> - it 'should return groonga results', (done) -> - db.command 'status', (error, data) -> - throw error if error - should.exist(data.version) - done() - - describe 'duplicated #close call', -> - it 'should raise an exception', -> - db.close() - (-> - db.close() - ).should.throw('Database already closed') - - describe '#commandSync for closed database', -> - it 'should raise an exception', -> - db.close() - (-> - db.commandSync 'status' - ).should.throw('Database already closed') - - describe '#command for closed database', -> - it 'should return an error', -> - db.close() - (-> - db.command 'status', (error, data) -> - # do nothing - ).should.throw('Database already closed') - -describe 'empty database', -> - db = new nroonga.Database() - - describe '#dump', -> - it 'should return empty string', -> - result = db.commandSync('dump') - should.equal(result, '') - -describe 'database whose name is not string', -> - it 'should throw an exception', -> - (-> - new nroonga.Database(1) - ).should.throw() - -describe 'database with data stored', -> - it 'should select records', (done) -> - withTestDatabase (db) -> - matched = db.commandSync('select', table: 'Site') - matched[0][0][0].should.equal(3) - done() - - it 'should select records ignoring the null valued option', (done) -> - withTestDatabase (db) -> - matched = db.commandSync('select', table: 'Site', query: null) - matched[0][0][0].should.equal(3) - done() - - it 'should search by query', (done) -> - withTestDatabase (db) -> - matched = db.commandSync 'select', - table: 'Site' - match_columns: 'title' - query: 'ruby' - matched[0][0][0].should.equal(1) - done() - - it 'should search by query including space', (done) -> - withTestDatabase (db) -> - matched = db.commandSync 'select', - table: 'Site' - match_columns: 'title' - query: 'search ranguba' - matched[0][0][0].should.equal(1) - done() - - it 'should dump all records', (done) -> - withTestDatabase (db) -> - result = db.commandSync('dump', tables: 'Site') - expected_dump = 'table_create Site TABLE_HASH_KEY ShortText\n' + - 'column_create Site title COLUMN_SCALAR ShortText\n\n' + - 'table_create Terms TABLE_PAT_KEY ' + - 'ShortText --default_tokenizer TokenBigram ' + - '--normalizer NormalizerAuto\n\n' + - 'load --table Site\n' + - '[\n' + - '["_key","title"],\n' + - '["http://groonga.org/","groonga - An open-source ' + - 'fulltext search engine and column store"],\n' + - '["http://groonga.rubyforge.org/","Fulltext search by ' + - 'Ruby with groonga - Ranguba"],\n' + - '["http://mroonga.github.com/","Groonga storage ' + - 'engine - Fast fulltext search on MySQL"]\n' + - ']\n\n' + - 'column_create Terms entry_title ' + - 'COLUMN_INDEX|WITH_POSITION Site title' - - result.should.equal(expected_dump) - done() -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170911/c9d6a730/attachment-0001.htm