Skip to content

Commit e4ffdb4

Browse files
committed
Merge pull request #140 from michael/more-tests
More tests
2 parents 1870aec + 67b35e3 commit e4ffdb4

File tree

2 files changed

+94
-18
lines changed

2 files changed

+94
-18
lines changed

test/test.repo.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var test = require('tape');
2+
var Github = require("../");
3+
var test_user = require('./user.json');
4+
5+
test("Repo API", function(t) {
6+
var timeout = setTimeout(function () { t.fail(); }, 100000);
7+
var github = new Github({
8+
username: test_user.USERNAME,
9+
password: test_user.PASSWORD,
10+
auth: "basic"
11+
});
12+
var repo = github.getRepo('michael', 'github');
13+
14+
t.test('repo.show', function(q) {
15+
repo.show(function(err, res) {
16+
q.error(err, 'show repo');
17+
q.equals(res.full_name, 'michael/github', 'repo name');
18+
q.end();
19+
});
20+
});
21+
22+
t.test('repo.contents', function(q) {
23+
repo.contents('master', './', function(err, res) {
24+
q.error(err, 'get repo contents');
25+
q.end();
26+
});
27+
});
28+
29+
t.test('repo.fork', function(q) {
30+
repo.fork(function(err, res) {
31+
q.error(err, 'test fork repo');
32+
q.end();
33+
});
34+
});
35+
36+
//@TODO repo.branch, repo.pull
37+
38+
t.test('repo.listBranches', function(q) {
39+
repo.listBranches(function(err, res) {
40+
q.error(err, 'list branches');
41+
q.end();
42+
});
43+
});
44+
45+
clearTimeout(timeout);
46+
t.end();
47+
48+
});

test/test.user.js

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,69 @@ test("User API", function(t) {
1111
});
1212
var user = github.getUser();
1313

14-
user.orgs(function(err, res) {
15-
t.error(err, 'user orgs');
14+
t.test('user.orgs', function(q) {
15+
user.orgs(function(err, res) {
16+
q.error(err, 'user orgs');
17+
q.end();
18+
});
1619
});
1720

18-
user.gists(function(err, res) {
19-
t.error(err, 'user gists');
21+
t.test('user.gists', function(q) {
22+
user.gists(function(err, res) {
23+
q.error(err, 'user gists');
24+
q.end();
25+
});
2026
});
2127

22-
user.notifications(function(err, res) {
23-
t.error(err, 'user notifications');
28+
t.test('user.notifications', function(q) {
29+
user.notifications(function(err, res) {
30+
q.error(err, 'user notifications');
31+
q.end();
32+
});
2433
});
2534

26-
user.show('ingalls', function(err, res) {
27-
t.error(err, 'user show');
35+
t.test('user.show', function(q) {
36+
user.show('ingalls', function(err, res) {
37+
q.error(err, 'user show');
38+
q.end();
39+
});
2840
});
2941

30-
user.userRepos(test_user.USERNAME, function(err, res) {
31-
t.error(err, 'alt user repos');
42+
t.test('user.userRepos', function(q) {
43+
user.userRepos(test_user.USERNAME, function(err, res) {
44+
q.error(err, 'alt user repos');
45+
q.end();
46+
});
3247
});
3348

34-
user.userGists(test_user.USERNAME, function(err, res) {
35-
t.error(err, 'alt user gists');
49+
t.test('user.userGists', function(q) {
50+
user.userGists(test_user.USERNAME, function(err, res) {
51+
q.error(err, 'alt user gists');
52+
q.end();
53+
});
3654
});
3755

38-
user.orgRepos('openaddresses', function(err, res) {
39-
t.error(err, 'org users');
56+
t.test('user.orgRepos', function(q) {
57+
user.orgRepos('openaddresses', function(err, res) {
58+
q.error(err, 'org users');
59+
q.end();
60+
});
4061
});
4162

42-
user.follow('ingalls', function(err, res) {
43-
t.error(err, 'follow ingalls');
63+
t.test('user.follow', function(q) {
64+
user.follow('ingalls', function(err, res) {
65+
q.error(err, 'follow ingalls');
66+
q.end();
67+
});
4468
});
4569

46-
user.unfollow('ingalls', function(err, res) {
47-
t.error(err, 'unfollow ingalls');
70+
t.test('user.unfollow', function(q) {
71+
user.unfollow('ingalls', function(err, res) {
72+
q.error(err, 'unfollow ingalls');
73+
q.end();
74+
});
4875
});
76+
4977
clearTimeout(timeout);
5078
t.end();
5179

0 commit comments

Comments
 (0)