• R/O
  • HTTP
  • SSH
  • HTTPS

zephyr: Commit

This repository is for zephyr, which is implemented for a GUI of Eos.


Commit MetaInfo

Revision94dd6f2d88710cba365bac9ec73b98ab4deae527 (tree)
Time2016-02-04 04:16:24
Authorhimetani_cafe <fumifumi@yasu...>
Commiterhimetani_cafe

Log Message

[TEST] eos execution parameter check done.

Change Summary

Incremental Difference

--- a/server/class/Eos.js
+++ b/server/class/Eos.js
@@ -42,6 +42,8 @@ function hasOneProperty(options) {
4242 if(options.length === 0) {
4343 var errorMsg = 'At least one option is required.';
4444 throw new Error(errorMsg);
45+ } else {
46+ resolve();
4547 }
4648 });
4749 }
@@ -182,67 +184,14 @@ function validate(command, options, workspaceId) {
182184
183185 // do validation
184186 return Promise.all(promises)
185- .then(function() {
186- resolve('Success');
187- })
188- .catch(function(error) {
189- reject(error);
190- });
191- });
192- });
193- /*
194- var invalidArgumentType = [];
195- var invalidOutputFileName = [];
196-
197- // output file Regexp
198- var outRegExp = /out|append/;
199-
200- options.forEach(function(o) {
201- // outFile name
202- if(outRegExp.test(ocfObj[o.name].arg[i].argType)) {
203- if(workspace.indexOf(o.arguments[i]) > -1) {
204- invalidOutputFileName.push({name: o.name, file: arg});
205- }
206- }
207- });
208- });
209-
210- // check arguments number value
211- if(invalidArgumentsNumber.length > 0) {
212- errorMsg = '"arguments" properties is invalid number.\n';
213- invalidArgumentsNumber.forEach(function(i) {
214- errorMsg += i.name + ' expect to ' + i.expect + ', but actual ' + i.actual + '.\n';
215- });
216- throw new Error(errorMsg);
217- }
218-
219- // check arguments type
220- if(invalidArgumentType.length > 0) {
221- errorMsg = '"arguments" type is invalid.\n';
222- invalidArgumentType.forEach(function(i) {
223- if(i.file) {
224- errorMsg += i.name + ' ' + i.file + ' does not exist.\n';
225- } else {
226- errorMsg += i.name + ' expect to ' + i.expect + ', but actual ' + i.actual + '.\n';
227- }
228- });
229- throw new Error(errorMsg);
230- }
231-
232- // check outFile name
233- if(invalidOutputFileName.length > 0) {
234- errorMsg = 'output file name is invalid.\n';
235- invalidOutputFileName.forEach(function(i) {
236- errorMsg += i.name + ' ' + i.file + ' has already existed.\n';
237- });
238- throw new Error(errorMsg);
239- }
240- } catch(e) {
241- result.message = e.message;
242- return result;
243- }
187+ })
188+ .catch(function(error) {
189+ reject(error);
190+ })
191+ .then(function(r) {
192+ resolve();
193+ })
244194 });
245- */
246195 }
247196
248197 /**
--- a/test/mocha/Eos.test.js
+++ b/test/mocha/Eos.test.js
@@ -8,6 +8,7 @@
88 chai.should();
99
1010 var db = require('../../server/class/DB').instance;
11+ var testCommand = require('./testCommand.json');
1112
1213 var test1 = `
1314 /**
@@ -83,31 +84,37 @@
8384 return eos.validate('dcdFilePrint', [{name: '-r', arguments: [1,2,3]}, { name: '-i', arguments: ['file1.txt']}, { name: '-o', arguments: ['file1.txt']} ]).should.be.rejectedWith(Error, 'Invalid outfile name.');
8485 });
8586
86- /*
87- describe(test2, function() {
87+ });
8888
89+ describe(test2, function() {
8990 it('should return true when all options is proper.', function() {
9091 var result = eos.toExecString('dcdFilePrint', [{name: '-r', arguments: [1,2,3]}, { name: '-i', arguments: ['file1.txt']}, { name: '-o', arguments: ['file3.txt']} ]);
9192 expect(result).to.equal('dcdFilePrint -r 1 2 3 -s 10 -e 100 -d 10 -m 0 -i file1.txt -o file3.txt');
9293 });
93- */
9494 });
9595
96- describe('getFiles', function() {
97- before(function() {
98- process.env.NODE_ENV = '';
99- return db.init()
100- .then(function() {
101- return Promise.all([db.test1(), db.test2(), db.testRest()])
102- });
103- });
104-
105- it('should be resolved with length 4', function() {
106- return expect(eos.getFiles('1f83f620-c1ed-11e5-9657-7942989daa00')).to.eventually.length(4);
107- });
108-
109- after(function() {
110- process.env.NODE_ENV = 'test';
96+ describe('getFiles', function() {
97+ before(function() {
98+ process.env.NODE_ENV = '';
99+ return db.init()
100+ .then(function() {
101+ return Promise.all([db.test1(), db.test2(), db.testRest()])
102+ });
103+ });
104+
105+ it('should be resolved with length 4', function() {
106+ return expect(eos.getFiles('1f83f620-c1ed-11e5-9657-7942989daa00')).to.eventually.length(4);
107+ });
108+
109+ it('should be resolved about testCommand', function() {
110+ var command = testCommand.command;
111+ var options = testCommand.options;
112+ var workspace = testCommand.workspace;
113+ return eos.validate(command, options, workspace).should.be.fulfilled;
114+ });
115+
116+ after(function() {
117+ process.env.NODE_ENV = 'test';
111118 });
112119 });
113120 });
--- /dev/null
+++ b/test/mocha/testCommand.json
@@ -0,0 +1,44 @@
1+{
2+ "command": "dcdFilePrint",
3+ "workspace": "1f83f620-c1ed-11e5-9657-7942989daa00",
4+ "options": [
5+ {
6+ "name": "-i",
7+ "arguments": [
8+ "debugRest.mrc"
9+ ]
10+ },
11+ {
12+ "name": "-o",
13+ "arguments": [
14+ "fsdafsadfasd"
15+ ]
16+ },
17+ {
18+ "name": "-r",
19+ "arguments": [
20+ 10,
21+ 100,
22+ 10
23+ ]
24+ },
25+ {
26+ "name": "-s",
27+ "arguments": [
28+ 10
29+ ]
30+ },
31+ {
32+ "name": "-e",
33+ "arguments": [
34+ 100
35+ ]
36+ },
37+ {
38+ "name": "-d",
39+ "arguments": [
40+ 10
41+ ]
42+ }
43+ ]
44+}
Show on old repository browser