Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Bugfix for test cases: wrong asynch handling for tests with 2 differe…
Browse files Browse the repository at this point in the history
…nt users
  • Loading branch information
stephan271 committed Dec 21, 2018
1 parent c0e21a4 commit 3be076e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
17 changes: 9 additions & 8 deletions test/DatasetLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ describe('Test DatasetLifecycle and the relation to Datasets', () => {
},
(tokenVal) => {
accessTokenIngestor = tokenVal;
});
utils.getToken(app, {
'username': 'archiveManager',
'password': 'aman'
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
utils.getToken(app, {
'username': 'archiveManager',
'password': 'aman'
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
});
});
});


it('adds a new raw dataset', function(done) {
request(app)
.post('/api/v2/RawDatasets?access_token=' + accessTokenIngestor)
Expand Down
58 changes: 29 additions & 29 deletions test/MessageHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ var testjob = {
"type": "retrieve",
"jobStatusMessage": "jobForwarded",
"datasetList": [{
"pid": "dummy",
"files": []
}],
"pid": "dummy",
"files": []
}],
"archiveReturnMessage": "will move to messageList",
"MessageHistory": []
}
Expand All @@ -135,26 +135,26 @@ var newMessage = {
}

var app
before( function(){
before(function() {
app = require('../server/server')
});

describe('Test DatasetLifecycle and the relation to Datasets', () => {
describe('Test MessageHistory in jobs', () => {
before((done) => {
utils.getToken(app, {
'username': 'ingestor',
'password': 'aman'
},
(tokenVal) => {
accessTokenIngestor = tokenVal;
});
utils.getToken(app, {
'username': 'archiveManager',
'password': 'aman'
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
utils.getToken(app, {
'username': 'archiveManager',
'password': 'aman'
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
});
});
});

Expand All @@ -172,10 +172,10 @@ describe('Test DatasetLifecycle and the relation to Datasets', () => {
res.body.should.have.property('type').and.equal('raw');
res.body.should.have.property('pid').and.be.string;
// store link to this dataset in datablocks
var pidtest=res.body['pid']
var pidtest = res.body['pid']
testDatasetLifecycle.id = pidtest
testDatasetLifecycle.datasetId = pidtest
testjob.datasetList[0].pid= pidtest
testjob.datasetList[0].pid = pidtest
pid = encodeURIComponent(res.body['pid']);
done();
});
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('Test DatasetLifecycle and the relation to Datasets', () => {
return done(err);
res.body.should.have.property('type').and.be.string;
idJob = res.body['id']
console.log("Jobid:",idJob)
console.log("Jobid:", idJob)
done();
});
});
Expand All @@ -252,24 +252,24 @@ describe('Test DatasetLifecycle and the relation to Datasets', () => {
.end(function(err, res) {
if (err)
return done(err);
console.log(res.body)
console.log(res.body)
done();
});
});


it('should delete the Job', function(done) {
request(app)
.delete('/api/v2/Jobs/' + idJob+ '?access_token=' + accessTokenIngestor)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if (err)
return done(err);
done();
});
});
it('should delete the Job', function(done) {
request(app)
.delete('/api/v2/Jobs/' + idJob + '?access_token=' + accessTokenIngestor)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if (err)
return done(err);
done();
});
});

it('should delete the DatasetLifecycle', function(done) {
request(app)
Expand Down
17 changes: 9 additions & 8 deletions test/ResetDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,18 @@ describe('Create Dataset and its Datablocks DatasetLifecycle, then reset Datablo
},
(tokenVal) => {
accessTokenIngestor = tokenVal;
});
utils.getToken(app, {
'username': 'archiveManager',
'password': 'aman'
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
utils.getToken(app, {
'username': 'archiveManager',
'password': 'aman'
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
done();
});
});
});


// first get existing datasets with the test archieId to allow to delete them


Expand Down

0 comments on commit 3be076e

Please sign in to comment.