-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate unit tests and integration (e2e) tests (#1207)
- Loading branch information
Showing
19 changed files
with
372 additions
and
353 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ terraform.* | |
!terraform.test.js | ||
crash.log | ||
/build | ||
/coverage |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const fs = require('fs'); | ||
const { exec } = require('../../../src/utils'); | ||
|
||
describe('CML e2e', () => { | ||
test('cml publish assets/logo.png --md', async () => { | ||
const output = await exec(`node ./bin/cml.js publish assets/logo.png --md`); | ||
|
||
expect(output.startsWith('![](')).toBe(true); | ||
}); | ||
|
||
test('cml publish assets/logo.png', async () => { | ||
const output = await exec(`node ./bin/cml.js publish assets/logo.png`); | ||
|
||
expect(output.startsWith('https://')).toBe(true); | ||
}); | ||
|
||
test('cml publish assets/logo.pdf --md', async () => { | ||
const title = 'this is awesome'; | ||
const output = await exec( | ||
`node ./bin/cml.js publish assets/logo.pdf --md --title '${title}'` | ||
); | ||
|
||
expect(output.startsWith(`[${title}](`)).toBe(true); | ||
}); | ||
|
||
test('cml publish assets/logo.pdf', async () => { | ||
const output = await exec(`node ./bin/cml.js publish assets/logo.pdf`); | ||
|
||
expect(output.startsWith('https://')).toBe(true); | ||
}); | ||
|
||
test('cml publish assets/test.svg --md', async () => { | ||
const title = 'this is awesome'; | ||
const output = await exec( | ||
`node ./bin/cml.js publish assets/test.svg --md --title '${title}'` | ||
); | ||
|
||
expect(output.startsWith('![](') && output.endsWith(`${title}")`)).toBe( | ||
true | ||
); | ||
}); | ||
|
||
test('cml publish assets/test.svg', async () => { | ||
const output = await exec(`node ./bin/cml.js publish assets/test.svg`); | ||
|
||
expect(output.startsWith('https://')).toBe(true); | ||
}); | ||
|
||
test('cml publish assets/logo.pdf to file', async () => { | ||
const file = `cml-publish-test.md`; | ||
|
||
await exec(`node ./bin/cml.js publish assets/logo.pdf --file ${file}`); | ||
|
||
expect(fs.existsSync(file)).toBe(true); | ||
await fs.promises.unlink(file); | ||
}); | ||
|
||
test('cml publish assets/vega-lite.json', async () => { | ||
const output = await exec( | ||
`node ./bin/cml.js publish --mime-type=application/json assets/vega-lite.json` | ||
); | ||
|
||
expect(output.startsWith('https://')).toBe(true); | ||
expect(output.includes('cml=json')).toBe(true); | ||
}); | ||
|
||
test('cml publish assets/test.svg in Gitlab storage', async () => { | ||
const { TEST_GITLAB_REPO: repo, TEST_GITLAB_TOKEN: token } = process.env; | ||
|
||
const output = await exec( | ||
`node ./bin/cml.js publish --repo=${repo} --token=${token} --gitlab-uploads assets/test.svg` | ||
); | ||
|
||
expect(output.startsWith('https://')).toBe(true); | ||
}); | ||
|
||
test('cml publish /nonexistent produces file error', async () => { | ||
await expect( | ||
exec('node ./bin/cml.js publish /nonexistent') | ||
).rejects.toThrowError('ENOENT'); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { exec } = require('../../../src/utils'); | ||
const fs = require('fs').promises; | ||
|
||
describe('CML e2e', () => { | ||
const path = 'check.md'; | ||
|
||
afterEach(async () => { | ||
try { | ||
await fs.unlink(path); | ||
} catch (err) {} | ||
}); | ||
|
||
test('cml send-github-check', async () => { | ||
const report = `## Test Check Report`; | ||
|
||
await fs.writeFile(path, report); | ||
process.env.GITHUB_ACTIONS && | ||
(await exec(`node ./bin/cml.js send-github-check ${path}`)); | ||
}); | ||
|
||
test('cml send-github-check failure with tile "CML neutral test"', async () => { | ||
const report = `## Hi this check should be neutral`; | ||
const title = 'CML neutral test'; | ||
const conclusion = 'neutral'; | ||
|
||
await fs.writeFile(path, report); | ||
process.env.GITHUB_ACTIONS && | ||
(await exec( | ||
`node ./bin/cml.js send-github-check ${path} --title "${title}" --conclusion "${conclusion}"` | ||
)); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { exec } = require('../../../src/utils'); | ||
const fs = require('fs').promises; | ||
|
||
describe('Comment integration tests', () => { | ||
const path = 'comment.md'; | ||
|
||
afterEach(async () => { | ||
try { | ||
await fs.unlink(path); | ||
} catch (err) {} | ||
}); | ||
|
||
test('cml send-comment to specific repo', async () => { | ||
const { | ||
TEST_GITHUB_REPO: repo, | ||
TEST_GITHUB_TOKEN: token, | ||
TEST_GITHUB_SHA: sha | ||
} = process.env; | ||
|
||
const report = `## Test Comment Report specific`; | ||
|
||
await fs.writeFile(path, report); | ||
await exec( | ||
`node ./bin/cml.js send-comment --repo=${repo} --token=${token} --commit-sha=${sha} ${path}` | ||
); | ||
}); | ||
|
||
test('cml send-comment to current repo', async () => { | ||
const report = `## Test Comment`; | ||
|
||
await fs.writeFile(path, report); | ||
await exec(`node ./bin/cml.js send-comment ${path}`); | ||
}); | ||
|
||
test('cml send-comment --publish to current repo', async () => { | ||
const report = `## Test Comment\n![](assets/logo.png)`; | ||
|
||
await fs.writeFile(path, report); | ||
await exec(`node ./bin/cml.js send-comment --publish ${path}`); | ||
}); | ||
}); |
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
File renamed without changes.
Oops, something went wrong.