-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathresources-config.js
More file actions
73 lines (68 loc) · 2.35 KB
/
Copy pathresources-config.js
File metadata and controls
73 lines (68 loc) · 2.35 KB
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
/*
* Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
var should = require('should');
var fs = require('fs');
var valcheck = require('core-util-is');
var testconfig = require('../etc/test-config.js');
var marklogic = require('../');
var q = marklogic.queryBuilder;
var db = marklogic.createDatabaseClient(testconfig.restWriterConnection);
var restAdminDB = marklogic.createDatabaseClient(testconfig.restAdminConnection);
describe('when configuring resource services', function(){
var serviceName = 'timeService';
var servicePath = './test-basic/data/timeService.xqy';
it('should write the resource service with positional parameters', function(done){
this.timeout(3000);
restAdminDB.config.resources.write(serviceName, 'xquery', fs.createReadStream(servicePath))
.result(function(response){
done();
})
.catch(done);
});
it('should write the resource service with named parameters', function(done){
this.timeout(3000);
restAdminDB.config.resources.write({
name: serviceName,
title: 'The Time Service',
description: 'About time.',
provider: 'Temporizers',
version: 0.1,
format: 'xquery',
source: fs.createReadStream(servicePath)
})
.result(function(response){
done();
})
.catch(done);
});
it('should read the resource service', function(done){
restAdminDB.config.resources.read(serviceName)
.result(function(source){
(!valcheck.isNullOrUndefined(source)).should.equal(true);
(typeof source).should.equal('string');
done();
})
.catch(done);
});
it('should list the resource services', function(done){
db.config.resources.list()
.result(function(response){
response.should.have.property('resources');
response.resources.should.have.property('resource');
response.resources.resource.length.should.be.above(0);
response.resources.resource.filter(function(item){return item.name === serviceName;}).
length.should.equal(1);
done();
})
.catch(done);
});
it('should delete the resource service', function(done){
restAdminDB.config.resources.remove(serviceName)
.result(function(response){
done();
})
.catch(done);
});
// TODO: test streaming of source and list
});