Skip to content

Commit

Permalink
Compile js from coffee; Migrate to mocha and should; Remove coffee de…
Browse files Browse the repository at this point in the history
…pendency
  • Loading branch information
wdavidw committed Nov 13, 2012
1 parent ded21f9 commit 2250432
Show file tree
Hide file tree
Showing 12 changed files with 357 additions and 91 deletions.
2 changes: 0 additions & 2 deletions index.js
@@ -1,4 +1,2 @@

require('coffee-script');

module.exports = require('./lib/hive');
262 changes: 262 additions & 0 deletions lib/hive.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -7,11 +7,13 @@
{ "name": "David Worms", "email": "david@adaltas.com" }
],
"dependencies": {
"coffee-script": "latest",
"thrift": "latest",
"each": "latest"
},
"devDependencies": {
"coffee-script": "latest",
"mocha": "latest",
"should": "latest"
},
"keywords": ["hive", "nosql", "hadoop"],
"main": "index",
Expand Down
Empty file modified samples/pipe.coffee 100755 → 100644
Empty file.
Empty file modified samples/query.coffee 100755 → 100644
Empty file.
Empty file modified samples/style_native.js 100755 → 100644
Empty file.
Empty file modified samples/style_sugar.js 100755 → 100644
Empty file.
File renamed without changes.
23 changes: 12 additions & 11 deletions test/EscapeTest.coffee
@@ -1,12 +1,16 @@

assert = require 'assert'
hive = require "#{__dirname}/.."
should = require 'should'
config = require './config'
hive = if process.env.EACH_COV then require '../lib-cov/hive' else require '../lib/hive'

client = hive.createClient config
client = null
before ->
client = hive.createClient config
after ->
client.end()

module.exports =
'Multi # Escape': (next) ->
describe 'escape', ->
it 'should honor "--" and "/* */"', (next) ->
count_before = 0
count_row = 0
client.multi_query("""
Expand Down Expand Up @@ -36,11 +40,8 @@ module.exports =
.on 'row', (row) ->
count_row++
.on 'error', (err) ->
assert.ifError err
should.not.exist err
.on 'end', (query) ->
assert.eql count_before, 2
assert.eql query, "show databases"
count_before.should.eql 2
query.should.eql "show databases"
next()
'Close': (next) ->
client.end()
next()
41 changes: 21 additions & 20 deletions test/MultiExecuteTest.coffee
@@ -1,12 +1,16 @@

assert = require 'assert'
hive = require "#{__dirname}/.."
should = require 'should'
config = require './config'
hive = if process.env.EACH_COV then require '../lib-cov/hive' else require '../lib/hive'

client = hive.createClient config
client = null
before ->
client = hive.createClient config
after ->
client.end()

module.exports =
'Multi # Execute # String': (next) ->
describe 'Multi # Execute', ->
it 'String', (next) ->
count_before = 0
count_end = 0
count_both = 0
Expand All @@ -24,18 +28,18 @@ module.exports =
-- load data
LOAD DATA LOCAL INPATH '#{__dirname}/data.csv' OVERWRITE INTO TABLE #{config.table};
""", (err) ->
assert.ifError err
assert.eql count_before, 3
assert.eql count_end, 1
assert.eql count_both, 1
should.not.exist err
count_before.should.eql 3
count_end.should.eql 1
count_both.should.eql 1
next()
execute.on 'before', (query) ->
count_before++
execute.on 'end', (query) ->
count_end++
execute.on 'both', (query) ->
count_both++
'Multi # Execute # Error': (next) ->
it 'Error', (next) ->
count_before = 0
count_error = 0
count_both = 0
Expand All @@ -45,20 +49,17 @@ module.exports =
-- create db
CREATE DATABASE IF NOT EXISTS #{config.db};
""", (err) ->
assert.ok err instanceof Error
assert.eql err.name, 'HiveServerException'
assert.eql count_before, 1
assert.eql count_error, 1
assert.eql count_both, 1
err.should.be.an.instanceof Error
err.name.should.eql 'HiveServerException'
count_before.should.eql 1
count_error.should.eql 1
count_both.should.eql 1
next()
execute.on 'before', (query) ->
count_before++
execute.on 'error', (err) ->
assert.ok err instanceof Error
assert.eql err.name, 'HiveServerException'
err.should.be.an.instanceof Error
err.name.should.eql 'HiveServerException'
count_error++
execute.on 'both', (query) ->
count_both++
'Close': (next) ->
client.end()
next()

0 comments on commit 2250432

Please sign in to comment.