-
Notifications
You must be signed in to change notification settings - Fork 103
/
http-yokozuna-client-test.js
83 lines (70 loc) · 2.34 KB
/
http-yokozuna-client-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var HttpClient = require('../../lib/http-client'),
should = require('should'),
helpers = require('./../test_helper');
var db, bucket, yzIndex;
describe('http-client-solr-tests', function() {
before(function(done) {
this.timeout(30000);
db = new HttpClient({port: 8098});
// Ensure unit tests don't collide with pre-existing buckets
bucket = 'users-riak-js-tests-solr';
yzIndex = 'riak-js-index-test';
var obj = {
email_s: 'test-search@gmail.com',
name_s: 'Testy Test for Riak Search'
};
db.saveBucket(bucket, {search_index: "_dont_index_"}, function (err) {
setTimeout(function () {
db.yokozuna.removeIndex(yzIndex, function (err) {
setTimeout(function () {
db.yokozuna.createIndex(yzIndex, function (err) {
setTimeout(function () {
db.saveBucket(bucket, {search_index: yzIndex}, function (err) {
setTimeout(function () {
db.save(bucket, 'test-search@gmail.com', obj, function (err, data, meta) {
setTimeout(function () {
done();
}, 1000);
});
}, 4000)
});
}, 1000)
});
}, 4000)
});
}, 4000);
});
});
after(function (done) {
helpers.cleanupBucket(bucket, done);
});
it('creates an index', function (done) {
db.yokozuna.getIndex(yzIndex, function (err, data) {
should.not.exist(err);
data.name.should.equal(yzIndex);
data.schema.should.equal('_yz_default');
done();
});
});
it('saves the index bucket property', function (done) {
db.saveBucket(bucket, { search_index: yzIndex }, function (err) {
should.not.exist(err);
done();
});
});
it('gets the index bucket property', function (done) {
db.getBucket(bucket, function (err, props) {
props.search_index.should.equal(yzIndex);
done();
});
});
it('Searching via Solr interface', function (done) {
db.yokozuna.find(yzIndex, 'email_s:test-search@gmail.com', function(err, data) {
should.not.exist(err);
should.exist(data);
data.docs[0].email_s.should.equal('test-search@gmail.com');
data.docs[0].name_s.should.equal('Testy Test for Riak Search');
done();
});
});
});