Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
groonga load test: add simple success cases
- Loading branch information
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| var assert = require('chai').assert; | ||
| var nodemock = require('nodemock'); | ||
| var Deferred = require('jsdeferred').Deferred; | ||
|
|
||
| var utils = require('../../test-utils'); | ||
|
|
||
| var express = require('express'); | ||
| var httpAdapter = require('../../../lib/adapter/http'); | ||
| var groongaAPI = require('../../../lib/adapter/api/groonga'); | ||
|
|
||
| suite('adapter/api: Groonga', function() { | ||
| suite('load', function() { | ||
| var connection; | ||
| var application; | ||
| var server; | ||
| var backend; | ||
|
|
||
| setup(function(done) { | ||
| utils.setupApplication() | ||
| .next(function(result) { | ||
| backend = result.backend; | ||
| server = result.server; | ||
| connection = result.connection; | ||
| application = result.application; | ||
| httpAdapter.register(application, { | ||
| prefix: '', | ||
| connection: connection, | ||
| plugins: [groongaAPI] | ||
| }); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| teardown(function() { | ||
| utils.teardownApplication({ | ||
| backend: backend, | ||
| server: server, | ||
| connection: connection | ||
| }); | ||
| }); | ||
|
|
||
| function pushSuccessResponse() { | ||
| backend.reserveResponse(function(request) { | ||
| return utils.createReplyPacket(request, | ||
| { | ||
| statusCode: 200, | ||
| body: true | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| suite('success', function() { | ||
| suite('key only', function() { | ||
| test('one', function(done) { | ||
| pushSuccessResponse(); | ||
| var body = [ | ||
| { | ||
| _key: 'alice' | ||
| } | ||
| ] | ||
| utils.post('/d/load?table=Users', JSON.stringify(body)) | ||
| .next(function(response) { | ||
| try { | ||
| assert.deepEqual([1], JSON.parse(response.body)[1]); | ||
| done(); | ||
| } catch (error) { | ||
| done(error); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| test('multiple', function(done) { | ||
| pushSuccessResponse(); | ||
| pushSuccessResponse(); | ||
| var body = [ | ||
| { | ||
| _key: 'alice' | ||
| }, | ||
| { | ||
| _key: 'bob' | ||
| } | ||
| ] | ||
| utils.post('/d/load?table=Users', JSON.stringify(body)) | ||
| .next(function(response) { | ||
| try { | ||
| assert.deepEqual([2], JSON.parse(response.body)[1]); | ||
| done(); | ||
| } catch (error) { | ||
| done(error); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| suite('failure', function() { | ||
| }); | ||
| }); | ||
| }); | ||
|
|