-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature][s] Adds before/after hook to handle test organization
- Loading branch information
Showing
3 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters