Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make ownerEmail optional and add minimal dataset testing #364

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/datasets/dto/create-dataset.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class CreateDatasetDto extends OwnableDto {
description:
"Email of owner or of custodian of the data set. The string may contain a list of emails, which should then be seperated by semicolons.",
})
@IsOptional()
@IsEmail()
readonly ownerEmail?: string;

Expand Down
26 changes: 26 additions & 0 deletions test/DerivedDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { TestData } = require("./TestData");
var accessToken = null;
var accessTokenArchiveManager = null;
var pid = null;
var minPid = null;

describe("DerivedDataset: Derived Datasets", () => {
beforeEach((done) => {
Expand Down Expand Up @@ -46,6 +47,22 @@ describe("DerivedDataset: Derived Datasets", () => {
});
});

it("adds a new minimal derived dataset", async () => {
return request(appUrl)
.post("/api/v3/Datasets")
.send(TestData.DerivedCorrectMin)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessToken}` })
.expect(200)
.expect("Content-Type", /json/)
.then((res) => {
res.body.should.have.property("owner").and.be.string;
res.body.should.have.property("type").and.equal("derived");
res.body.should.have.property("pid").and.be.string;
minPid = encodeURIComponent(res.body["pid"]);
});
});

it("adds a new derived dataset", async () => {
return request(appUrl)
.post("/api/v3/Datasets")
Expand Down Expand Up @@ -178,4 +195,13 @@ describe("DerivedDataset: Derived Datasets", () => {
.expect(200)
.expect("Content-Type", /json/);
});

it("should delete a minimal derived dataset", async () => {
return request(appUrl)
.delete("/api/v3/Datasets/" + minPid)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenArchiveManager}` })
.expect(200)
.expect("Content-Type", /json/);
});
});
27 changes: 27 additions & 0 deletions test/RawDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { TestData } = require("./TestData");

var accessToken = null;
var pid = null;
var minPid = null;
var accessProposalToken = null;
var accessTokenArchiveManager = null;

Expand Down Expand Up @@ -74,6 +75,23 @@ describe("RawDataset: Raw Datasets", () => {
});
});

it("adds a new minimal raw dataset", async () => {
return request(appUrl)
.post("/api/v3/Datasets")
.send(TestData.RawCorrectMin)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessToken}` })
.expect(200)
.expect("Content-Type", /json/)
.then((res) => {
res.body.should.have.property("owner").and.be.string;
res.body.should.have.property("type").and.equal("raw");
res.body.should.have.property("pid").and.be.string;

minPid = encodeURIComponent(res.body["pid"]);
});
});

it("adds a new raw dataset", async () => {
return request(appUrl)
.post("/api/v3/Datasets")
Expand Down Expand Up @@ -269,6 +287,15 @@ describe("RawDataset: Raw Datasets", () => {
.expect("Content-Type", /json/);
});

it("should delete this minimal raw dataset", async () => {
return request(appUrl)
.delete("/api/v3/datasets/" + minPid)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenArchiveManager}` })
.expect(200)
.expect("Content-Type", /json/);
});

it("should delete this proposal", async () => {
return request(appUrl)
.delete("/api/v3/Proposals/" + proposalId)
Expand Down
23 changes: 23 additions & 0 deletions test/TestData.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const TestData = {
type: "base",
},

RawCorrectMin: {
ownerGroup: faker.company.name(),
creationLocation: faker.address.city(),
principalInvestigator: faker.internet.userName(),
type: "raw",
creationTime: faker.date.past(),
sourceFolder: faker.system.directoryPath(),
owner: faker.internet.userName(),
contactEmail: faker.internet.email(),
},

RawCorrect: {
principalInvestigator: "[email protected]",
endTime: "2011-09-14T06:31:25.000Z",
Expand Down Expand Up @@ -323,6 +334,18 @@ const TestData = {
history: {},
},

DerivedCorrectMin: {
investigator: faker.internet.email(),
inputDatasets: [faker.system.filePath()],
usedSoftware: [faker.internet.url()],
owner: faker.internet.userName(),
contactEmail: faker.internet.email(),
sourceFolder: faker.system.directoryPath(),
creationTime: faker.date.past(),
ownerGroup: faker.random.alphaNumeric(6),
type: "derived",
},

DerivedCorrect: {
investigator: "[email protected]",
inputDatasets: ["/data/input/file1.dat"],
Expand Down