Skip to content

Commit

Permalink
[feature][s] Adds before/after hook to handle test organization
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos committed Nov 24, 2020
1 parent 8e43cc6 commit f8dc86f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
48 changes: 40 additions & 8 deletions mocha/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
import mocha from 'mocha'
import chai from 'chai'
import axios from "axios";
import fs from "fs";
import mocha from "mocha";
import chai from "chai";

const expect = chai.expect
const uuid = () => Math.random().toString(36).slice(2) + "_test";
const config = JSON.parse(fs.readFileSync("cypress.json"));
const orgName = config.env.ORG_NAME_SUFFIX + uuid();
const packageName = uuid(); // TODO unused so far (saved for later, for creating a resource)
const headers = {
authorization: config.env.API_KEY,
"content-type": "application/json"
};

describe('test', ()=> {
it('should run', () =>{
expect(true).to.be.eq(true)
})
})
describe("Test CKAN integration through CKAN client library", () => {
before(async () => {
// creates an organization to be the owner of test resources
await axios.post(
`${config.baseUrl}/api/3/action/organization_create`,
{ name: orgName },
{ headers: headers }
);
});

after(async () => {
// deletes the organization owner of test resources
await axios.post(
`${config.baseUrl}/api/3/action/organization_delete`,
{ id: orgName },
{ headers: headers }
);
});

// TODO replace w/ meaningful test, this one is merely testing the before hook
it("should list the test organization", async () => {
const org = await axios.get(
`${config.baseUrl}/api/3/action/organization_show?id=${orgName}`,
{ headers: headers }
);
chai.expect(org.success).to.be.eq(true);
});
});
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:mocha-watch": "npm run test:ckan -- --watch"
},
"dependencies": {
"axios": "^0.21.0",
"chai": "^4.2.0",
"cypress": "^4.9.0",
"cypress-file-upload": "^4.0.7",
Expand Down

0 comments on commit f8dc86f

Please sign in to comment.