-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
39 lines (32 loc) · 1.11 KB
/
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
const test = require('tape');
const path = require('path');
// config options first
const options = {
token: '',
username: '',
repository: '',
httpProxy: ''
};
if (options.token == '' || options.username == '' || options.repository == '') {
throw new Error('Please Edit file to config options first.');
}
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
(async () => {
const github = require('.')({
token: options.token,
repository: `https://github.com/${options.username}/${options.repository}`,
branch: options.branch,
httpProxy: options.httpProxy
});
console.log('wait for init.');
while(!github.isInitialized()) await sleep(100);
test('Upload readme to repository', async function(assert) {
assert.deepEqual(await github.upload({
data: path.resolve(__dirname, 'readme.md'),
filename: 'readme.txt'
}), {'filename': 'readme.txt', 'url':`https://cdn.jsdelivr.net/gh/${options.username}/${options.repository}@${options.branch}/readme.txt`});
assert.end()
})
})()