/
github-test.js
66 lines (49 loc) · 1.71 KB
/
github-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
53
54
55
56
57
58
59
60
61
62
63
64
(function() {
// Helpers
// -------
function randomString(length) {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var res = '';
for (var i=0; i<length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
res += chars.substring(rnum,rnum+1);
}
return res;
}
var USERNAME = "github-api-test",
PASSWORD = "api-test-12",
REPO = "github-api-test";
suite('Github', function(){
setup(function() {
// ...
});
suite('#Github API', function(){
test('should return repo information', function() {
var github = new Github({username: USERNAME, password: PASSWORD, auth: "basic"});
var repo = github.getRepo(REPO);
repo.show(function(err, repo) {
// TODO: implement
});
});
test('should be capable of returning all commits', function () {
var github = new Github({username: USERNAME, password: PASSWORD, auth: "basic"});
var repo = github.getRepo(REPO);
repo.list_commits(function(err, res) {
//console.log(err, res)
});
})
test('should be capable of writing files', function() {
var github = new Github({username: USERNAME, password: PASSWORD, auth: "basic"});
var repo = github.getRepo(REPO);
repo.write(randomString(20) + ".md", "h3. Hello World!", function(err, commit) {
// TODO:
repo.write("path/to/"+randomString(20) + ".md", "h3. Hello World!", function(err, commit) {
// TODO:
});
});
});
test('should be capable of wrting files to directories that do not yet exist', function() {
});
});
});
}).call(this);