Skip to content

Instantly share code, notes, and snippets.

@timoxley
Created October 14, 2011 13:59
Show Gist options
  • Save timoxley/1287187 to your computer and use it in GitHub Desktop.
Save timoxley/1287187 to your computer and use it in GitHub Desktop.
Riak TestServer usage
var Spine = require('../../lib/spine')
require('../../lib/spine-riak')
TestServer = require('riak-js').TestServer
var path = require('path')
var Config = require('../../config')
var testCase = require('nodeunit').testCase;
var db = require('riak-js').getClient({port: Config.riakPort, debug: Config.debug})
var ts = new TestServer({binDir: Config.riakBinDir, tempDir: path.normalize(process.cwd() + '/.riaktest')})
var tests = undefined
tests = {
init: {
'setup test server': function (test) {
ts.prepare(function() {
console.log("PREPARED")
ts.start(function() {
console.log('STARTED')
db.ping(function(err, data, meta) {
console.log('PING')
test.done()
})
})
})
}
},
run: testCase({
setUp: function(callback) {
callback()
},
tearDown: function(callback) {
ts.clear(function() {
callback()
})
},
'is sane': function(test) {
console.log("SHANE")
test.expect(3)
test.ok(Spine.Model.Riak)
var Test = Spine.Model.sub();
Test.configure('Test', 'a')
Test.extend(Spine.Model.Riak);
test.ok(Test.saveRiak)
test.ok(Test.loadRiak)
test.done()
}
}),
shutdown: {
'shutdown test server': function(test) {
ts.stop(function(){
test.done()
})
}
}
}
module.exports = tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment