|
1 | | -var git = require('../'), |
2 | | - |
3 | | -exports.author = function(test) { |
4 | | - test.expect(2); |
5 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
6 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
7 | | - var author = commit.author(); |
8 | | - test.equals(error, null, 'There should be no error'); |
9 | | - test.notEqual(author, null, 'Author should not be null'); |
10 | | - test.done(); |
11 | | - }); |
12 | | - }); |
13 | | -}; |
14 | | - |
15 | | -exports.authorName = function(test) { |
16 | | - test.expect(1); |
17 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
18 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
19 | | - var author = commit.author(); |
20 | | - var name = author.name(); |
21 | | - test.equals(name, 'Michael Robinson', 'The author name should match expected value'); |
22 | | - test.done(); |
23 | | - }); |
24 | | - }); |
25 | | -}; |
26 | | - |
27 | | -exports.authorEmail = function(test) { |
28 | | - test.expect(1); |
29 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
30 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
31 | | - var author = commit.author(); |
32 | | - var email = author.email(); |
33 | | - test.equals(email, 'mike@panmedia.co.nz', 'The author email should match expected value'); |
34 | | - test.done(); |
35 | | - }); |
36 | | - }); |
37 | | -}; |
38 | | - |
39 | | -exports.committerName = function(test) { |
40 | | - test.expect(1); |
41 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
42 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
43 | | - var committer = commit.committer(); |
44 | | - var name = committer.name(); |
45 | | - test.equals(name, 'Michael Robinson', 'The author name should match expected value'); |
46 | | - test.done(); |
47 | | - }); |
48 | | - }); |
49 | | -}; |
50 | | - |
51 | | -exports.committerEmail = function(test) { |
52 | | - test.expect(1); |
53 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
54 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
55 | | - var committer = commit.committer(); |
56 | | - var email = committer.email(); |
57 | | - test.equals(email, 'mike@panmedia.co.nz', 'The committer email should match expected value'); |
58 | | - test.done(); |
59 | | - }); |
60 | | - }); |
61 | | -}; |
62 | | - |
63 | | -/** |
64 | | - * Test that improper commit ID's result in an error message |
65 | | - */ |
66 | | -exports.improperCommitId = function(test) { |
67 | | - test.expect(1); |
68 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
69 | | - repository.getCommit('not a proper commit sha', function(error, commit) { |
70 | | - test.notEqual(error, null, 'Error should occur'); |
71 | | - test.done(); |
72 | | - }); |
73 | | - }); |
74 | | -}; |
75 | | - |
76 | | -/** |
77 | | - * Test that retreiving walking a given commit's history works as expected. |
78 | | - */ |
79 | | -exports.history = function(test) { |
80 | | - test.expect(4); |
81 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
82 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
83 | | - test.equals(null, error, 'Getting latest branch commit should not error'); |
84 | | - var historyCount = 0; |
85 | | - var expectedHistoryCount = 364; |
86 | | - commit.history().on('commit', function(commit) { |
87 | | - historyCount++; |
88 | | - }).on('end', function(commits) { |
89 | | - test.equals(null, error, 'There should be no errors'); |
90 | | - test.equals(historyCount, expectedHistoryCount); |
91 | | - test.equals(commits.length, expectedHistoryCount); |
92 | | - test.done(); |
93 | | - }).on('error', function(error) { |
94 | | - test.equals(null, error, 'There should be no errors'); |
95 | | - test.ok(false, 'There should be no errors'); |
96 | | - }).start(); |
97 | | - }); |
98 | | - }); |
99 | | -}; |
100 | | - |
101 | | -/** |
102 | | - * Test that retreiving master branch's HEAD commit works as expected. |
103 | | - */ |
104 | | -exports.masterHead = function(test) { |
105 | | - test.expect(1); |
106 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
107 | | - repository.getBranch('master', function(error, branch) { |
108 | | - var sha = branch.sha(); |
109 | | - repository.getCommit(sha, function(error, commit) { |
110 | | - test.equals(error, null, 'Getting latest branch commit should not error'); |
111 | | - test.done(); |
112 | | - }); |
113 | | - }); |
114 | | - }); |
115 | | -}; |
116 | | - |
117 | | -/** |
118 | | - * Test that retreiving parent works as expected. |
119 | | - * |
120 | | - * @param {Object} test |
121 | | - */ |
122 | | -exports.parents = function(test) { |
123 | | - test.expect(3); |
124 | | - git.Repo.open('repos/workdir/.git', function(error, repository) { |
125 | | - repository.getCommit(historyCountKnownSHA, function(error, commit) { |
126 | | - commit.getParents(function(error, parents) { |
127 | | - test.equals(parents.length, 1, 'Commit should have exactly one parent'); |
128 | | - var sha = parents[0].sha(); |
129 | | - test.equals(error, null, 'Getting parent SHA should not error'); |
130 | | - test.equals(sha, 'ecfd36c80a3e9081f200dfda2391acadb56dac27', 'Parent SHA should match expected value'); |
131 | | - test.done(); |
132 | | - }); |
133 | | - }); |
134 | | - }); |
135 | | -}; |
136 | | - |
137 | 1 | /** |
138 | 2 | * Test that retrieving and walking a commit's tree works as expected. |
139 | 3 | */ |
|
0 commit comments