-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.test.js
52 lines (44 loc) · 1.72 KB
/
basic.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-env mocha */
globalThis.isMocha = !process.env.CI
const lib = require('gh-helpers')
const assert = require('assert')
describe('basic usage', () => {
const github = lib()
it('test import', async function () {
const defBranch = await github.getDefaultBranch()
console.log('Default branch', defBranch)
assert(defBranch === 'main' || defBranch === 'master')
})
it('test using', async function () {
const recentCommits = await github.using({ owner: 'extremeheat', repo: 'LXL' }).getRecentCommitsInRepo(20)
console.log('Recent commits in extremeheat/LXL', recentCommits)
})
it('PR checks', async function () {
// test on https://github.com/extremeheat/gh-helpers/pull/16
const checks = await github.waitForPullRequestChecks(16)
console.log('PR Checks for #16', checks)
})
it('listing artifacts', async function () {
const artifacts = await github.artifacts.list()
console.log('List of Artifacts on Repo', artifacts)
})
it('artifact read write', async function () {
// Test upload
const fileA = { hello: 'world' }
const ret = await github.artifacts.createTextArtifact('ci-test', {
fileA: JSON.stringify(fileA)
}, {
retentionDays: 1
})
console.log('Artifact written', ret)
// wait a few seconds
await new Promise(resolve => setTimeout(resolve, 20 * 2000))
const newList = await github.artifacts.list()
console.log('List of Artifacts on Repo', newList)
assert(newList.length)
// Test download
const downloaded = await github.artifacts.readTextArtifact(ret.id)
console.log('Read Artifact', downloaded)
assert(downloaded.fileA.includes('world'))
}).timeout(20 * 9000)
})