-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathdeleteByRange-test.ts
120 lines (118 loc) · 4.08 KB
/
deleteByRange-test.ts
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { assert } from 'chai';
import * as figc from 'figc';
import { createClient } from '../lib/solr';
import * as sassert from './utils/sassert';
import * as versionUtils from '../lib/utils/version';
const config = figc(__dirname + '/config.json');
const client = createClient(config.client);
const basePath = [config.client.path, config.client.core]
.join('/')
.replace(/\/$/, '');
describe('Client', function () {
describe('#deleteByRange(field,start,stop,callback)', function () {
it('should delete all documents between `start` and `stop` on the field `fied`', async function () {
const field = 'last_update_dt';
const start = new Date();
const stop = new Date();
stop.setDate(stop.getDate() - 1);
await client.deleteByRange(field, start, stop);
});
});
//TODO
// describe('#deleteByRange(field,start,stop,{softCommit : true },callback)', function () {
// it('should delete all documents between `start` and `stop` on the field `fied` with the soft commit option enabled', async function () {
// const field = 'last_update_dt';
// const start = new Date();
// const stop = new Date();
// stop.setDate(stop.getDate() - 1);
// const request = client.deleteByRange(
// field,
// start,
// stop,
// { softCommit: true },
// function (err, data) {
// if (
// client.solrVersion &&
// versionUtils.version(client.solrVersion) >= versionUtils.Solr4_0
// ) {
// assert.equal(
// request.path,
// basePath + '/update?softCommit=true&wt=json'
// );
// } else {
// assert.equal(
// request.path,
// basePath + '/update/json?softCommit=true&wt=json'
// );
// }
// dataOk(data);
// done();
// }
// );
// });
// });
// describe('#deleteByRange(field,start,stop,{commitWithin : 10000},callback)', function () {
// it('should delete all documents between `start` and `stop` on the field `fied` and commit changes within 10s', async function () {
// const field = 'last_update_dt';
// const start = new Date();
// const stop = new Date();
// stop.setDate(stop.getDate() - 1);
// const request = client.deleteByRange(
// field,
// start,
// stop,
// { commitWithin: 10000 },
// function (err, data) {
// if (
// client.solrVersion &&
// versionUtils.version(client.solrVersion) >= versionUtils.Solr4_0
// ) {
// assert.equal(
// request.path,
// basePath + '/update?commitWithin=10000&wt=json'
// );
// } else {
// assert.equal(
// request.path,
// basePath + '/update/json?commitWithin=10000&wt=json'
// );
// }
// dataOk(data);
// done();
// }
// );
// });
// });
// describe('#deleteByRange(field,start,stop,{commit : true},callback)', function () {
// it('should delete all documents between `start` and `stop` on the field `fied` and hard commit changes', async function () {
// const field = 'last_update_dt';
// const start = new Date();
// const stop = new Date();
// stop.setDate(stop.getDate() - 1);
// const request = client.deleteByRange(
// field,
// start,
// stop,
// { commit: true },
// function (err, data) {
// if (
// client.solrVersion &&
// versionUtils.version(client.solrVersion) >= versionUtils.Solr4_0
// ) {
// assert.equal(
// request.path,
// basePath + '/update?commit=true&wt=json'
// );
// } else {
// assert.equal(
// request.path,
// basePath + '/update/json?commit=true&wt=json'
// );
// }
// dataOk(data);
// done();
// }
// );
// });
// });
});