Skip to content

Commit

Permalink
Added env var option for DOI tests to be able to easily disable it in…
Browse files Browse the repository at this point in the history
… the CI environment when there are issues with Fabrica
  • Loading branch information
andrewbrazzatti committed May 21, 2024
1 parent 761f98a commit 2acd55a
Showing 1 changed file with 76 additions and 72 deletions.
148 changes: 76 additions & 72 deletions test/unit/services/DOIService.test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
describe('The DOI Service', function () {
before(function (done) {
if (
!sails.config.datacite.username ||
!sails.config.datacite.password ||
!sails.config.datacite.doiPrefix
!sails.config.datacite.username ||
!sails.config.datacite.password ||
!sails.config.datacite.doiPrefix
) {
this.skip();
} else {
done();
if (process.env.SKIP_DOI_TESTS === 'true') {
this.skip();
} else {
done();
}
}
});

let createdDoi = null
let oid = "xxxxxxxxx";
let record = {
metadata: {
citation_publication_date: '2021',
citation_title: 'New Test Publication',
citation_publisher: 'Research Labs GMBH',
creators: [{
given_name: "Test",
family_name: "Researcher"
},
{
given_name: "Test",
family_name: "Student"
}
]
}
}
let createdDoi = null
let oid = "xxxxxxxxx";
let record = {
metadata: {
citation_publication_date: '2021',
citation_title: 'New Test Publication',
citation_publisher: 'Research Labs GMBH',
creators: [{
given_name: "Test",
family_name: "Researcher"
},
{
given_name: "Test",
family_name: "Student"
}
]
}
}

it("Should create a DOI", function (done) {
this.timeout(25000);
Expand Down Expand Up @@ -74,58 +78,58 @@ describe('The DOI Service', function () {
});
});

it("Should create a draft DOI", function (done) {
this.timeout(25000);
sails.services.doiservice.publishDoi(oid, record, 'draft').then(result => {
sails.log.debug("DOI result: ")
sails.log.debug(result)
expect(result).to.not.be.null;
createdDoi = result
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});
it("Should create a draft DOI", function (done) {
this.timeout(25000);
sails.services.doiservice.publishDoi(oid, record, 'draft').then(result => {
sails.log.debug("DOI result: ")
sails.log.debug(result)
expect(result).to.not.be.null;
createdDoi = result
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});

it("Should register a DOI", function (done) {
this.timeout(25000);
sails.log.debug("Registering the created DOI: " + createdDoi)
sails.services.doiservice.changeDoiState(createdDoi,'register').then(result => {
expect(result).to.eq(true)
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});
it("Should register a DOI", function (done) {
this.timeout(25000);
sails.log.debug("Registering the created DOI: " + createdDoi)
sails.services.doiservice.changeDoiState(createdDoi, 'register').then(result => {
expect(result).to.eq(true)
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});

it("Should publish a DOI", function (done) {
this.timeout(25000);
sails.log.debug("Publishing the registered DOI: " + createdDoi)
sails.services.doiservice.changeDoiState(createdDoi,'publish').then(result => {
expect(result).to.eq(true)
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});
it("Should publish a DOI", function (done) {
this.timeout(25000);
sails.log.debug("Publishing the registered DOI: " + createdDoi)
sails.services.doiservice.changeDoiState(createdDoi, 'publish').then(result => {
expect(result).to.eq(true)
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});

it("Should hide a DOI", function (done) {
this.timeout(25000);
sails.log.debug("Hiding the published DOI: " + createdDoi)
sails.services.doiservice.changeDoiState(createdDoi,'hide').then(result => {
expect(result).to.eq(true)
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});
it("Should hide a DOI", function (done) {
this.timeout(25000);
sails.log.debug("Hiding the published DOI: " + createdDoi)
sails.services.doiservice.changeDoiState(createdDoi, 'hide').then(result => {
expect(result).to.eq(true)
done()
}).catch(error => {
fail("Exception thrown");
sails.log.error(error);
done();
});
});

});

0 comments on commit 2acd55a

Please sign in to comment.