-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathrunsDatastoreTest.js
More file actions
82 lines (63 loc) · 2.49 KB
/
Copy pathrunsDatastoreTest.js
File metadata and controls
82 lines (63 loc) · 2.49 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
74
75
76
77
78
79
80
81
82
var should = require('chai').should();
var runsDatastore = require('../../lib/server/datastores/runsDatastore');
describe('runsDatastore', function() {
var datastore = new runsDatastore();
var firstRunId = 333;
var secondRunId = 999;
it('should accept new runs', function() {
datastore.should.have.a.property('add').that.is.a('function');
datastore.add({
runId: firstRunId,
otherData: 123456789
}, 0);
datastore.add({
runId: secondRunId,
otherData: 'whatever'
}, 1);
});
it('should have stored the runs with a status "runnung"', function() {
datastore.should.have.a.property('get').that.is.a('function');
var firstRun = datastore.get(firstRunId);
firstRun.should.have.a.property('runId').that.equals(firstRunId);
firstRun.should.have.a.property('status').that.deep.equals({
statusCode: 'running'
});
var secondRun = datastore.get(secondRunId);
secondRun.should.have.a.property('runId').that.equals(secondRunId);
secondRun.should.have.a.property('status').that.deep.equals({
statusCode: 'awaiting',
position: 1
});
});
it('should have exactly 2 runs in the store', function() {
var runs = datastore.list();
runs.should.be.a('array');
runs.should.have.length(2);
runs[0].should.have.a.property('runId').that.equals(firstRunId);
});
it('shoud update statuses correctly', function() {
datastore.markAsComplete(firstRunId);
var firstRun = datastore.get(firstRunId);
firstRun.should.have.a.property('status').that.deep.equals({
statusCode: 'complete'
});
datastore.updatePosition(secondRunId, 0);
var secondRun = datastore.get(secondRunId);
secondRun.should.have.a.property('status').that.deep.equals({
statusCode: 'running'
});
datastore.markAsFailed(secondRunId, 'Error message');
secondRun = datastore.get(secondRunId);
secondRun.should.have.a.property('status').that.deep.equals({
statusCode: 'failed',
error: 'Error message'
});
});
it('should delete a run', function() {
datastore.delete(firstRunId);
var runs = datastore.list();
runs.should.be.a('array');
runs.should.have.length(1);
runs[0].should.have.a.property('runId').that.equals(secondRunId);
});
});