FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/raw-commit.js at v0.0.76 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
raw-commit.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
146 lines (119 loc) · 5.17 KB
Breadcrumbs
nodegit
/
test
/
raw-commit.js
Copy path
File metadata and controls
146 lines (119 loc) · 5.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
var
git
=
require
(
'../'
)
.
raw
,
rimraf
=
require
(
'rimraf'
)
,
path
=
require
(
'path'
)
;
var
testRepo
=
new
git
.
Repo
(
)
;
var
helper
=
{
// Test if obj is a true function
testFunction
:
function
(
test
,
obj
,
label
)
{
// The object reports itself as a function
test
(
typeof
obj
,
'function'
,
label
+
' reports as a function.'
)
;
// This ensures the repo is actually a derivative of the Function [[Class]]
test
(
toString
.
call
(
obj
)
,
'[object Function]'
,
label
+
' [[Class]] is of type function.'
)
;
}
,
// Test code and handle exception thrown
testException
:
function
(
test
,
fun
,
label
)
{
try
{
fun
(
)
;
test
(
false
,
label
)
;
}
catch
(
ex
)
{
test
(
true
,
label
)
;
}
}
}
;
/**
* Commit
*/
exports
.
constructor
=
function
(
test
)
{
test
.
expect
(
3
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
git
.
Commit
,
'Commit'
)
;
testRepo
.
open
(
path
.
resolve
(
'../.git'
)
,
function
(
err
)
{
// Ensure we get an instance of Commit
test
.
ok
(
new
git
.
Commit
(
testRepo
)
instanceof
git
.
Commit
,
'Invocation returns an instance of Commit'
)
;
test
.
done
(
)
;
}
)
;
}
;
/**
* Commit::Lookup
*/
exports
.
lookup
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testCommit
=
new
git
.
Commit
(
)
;
testOid
.
mkstr
(
'cb09e99e91d41705197e0fb60823fdc7df776691'
)
;
test
.
expect
(
8
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testCommit
.
lookup
,
'Commit::Lookup'
)
;
// Test repo argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testCommit
.
lookup
(
)
;
}
,
'Throw an exception if no repo'
)
;
// Test oid argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testCommit
.
lookup
(
testRepo
)
;
}
,
'Throw an exception if no oid'
)
;
// Test callback argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testCommit
.
lookup
(
testOid
)
;
}
,
'Throw an exception if no callback'
)
;
// Test that all arguments result correctly
helper
.
testException
(
test
.
ifError
,
function
(
)
{
testCommit
.
lookup
(
testRepo
,
testOid
,
function
(
)
{
}
)
;
}
,
'No exception is thrown with proper arguments'
)
;
testRepo
.
open
(
path
.
resolve
(
'../.git'
)
,
function
(
)
{
// Test invalid commit
testOid
.
mkstr
(
'100644'
)
;
testCommit
.
lookup
(
testRepo
,
testOid
,
function
(
err
)
{
test
.
notEqual
(
0
,
err
,
'Not a valid commit'
)
;
// Test valid commit
testOid
.
mkstr
(
'cb76e3c030ab29db332aff3b297dc39451a84762'
)
;
testCommit
.
lookup
(
testRepo
,
testOid
,
function
(
err
)
{
test
.
equals
(
null
,
err
,
'Valid commit'
)
;
//test.equals('Updated gitignore and raw-commit test', testCommit.messageShort(), 'Commit message is valid');
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
exports
.
fetchDetails
=
function
(
test
)
{
test
.
expect
(
14
)
;
var
testOid
=
new
git
.
Oid
(
)
;
testOid
.
mkstr
(
'cb76e3c030ab29db332aff3b297dc39451a84762'
)
;
testRepo
.
open
(
path
.
resolve
(
'../.git'
)
,
function
(
)
{
var
testCommit
=
new
git
.
Commit
(
)
;
testCommit
.
lookup
(
testRepo
,
testOid
,
function
(
error
,
commit
)
{
commit
.
fetchDetails
(
function
(
error
,
details
)
{
var
expected
=
{
sha
:
'cb76e3c030ab29db332aff3b297dc39451a84762'
,
message
:
'bumped package.json up\n'
,
time
:
1300145116
,
timeOffset
:
-
240
,
committer
:
{
name
:
'Tim Branyen'
,
email
:
'tim.branyen@gmail.com'
,
when
:
{
time
:
1300145116
,
offset
:
-
240
}
}
,
author
:
{
name
:
'Tim Branyen'
,
email
:
'tim.branyen@gmail.com'
,
when
:
{
time
:
1300145116
,
offset
:
-
240
}
}
,
parentCount
:
1
,
parentShas
:
[
'b1f941c62f508db5f392a6bb0ea1d591753a045b'
]
}
;
test
.
equals
(
expected
.
sha
,
details
.
sha
,
'Expected SHA does not match result'
)
;
test
.
equals
(
expected
.
message
,
details
.
message
,
'Expected message does not match result'
)
;
test
.
equals
(
expected
.
time
,
details
.
time
,
'Expected time does not match result'
)
;
test
.
equals
(
expected
.
offset
,
details
.
offset
,
'Expected offset does not match result'
)
;
test
.
equals
(
expected
.
committer
.
name
,
details
.
committer
.
name
,
'Expected committer.name does not match result'
)
;
test
.
equals
(
expected
.
committer
.
email
,
details
.
committer
.
email
,
'Expected committer.email does not match result'
)
;
test
.
equals
(
expected
.
committer
.
when
.
time
,
details
.
committer
.
when
.
time
,
'Expected committer.when.time does not match result'
)
;
test
.
equals
(
expected
.
committer
.
when
.
offset
,
details
.
committer
.
when
.
offset
,
'Expected committer.when.offset does not match result'
)
;
test
.
equals
(
expected
.
author
.
name
,
details
.
author
.
name
,
'Expected author.name does not match result'
)
;
test
.
equals
(
expected
.
author
.
email
,
details
.
author
.
email
,
'Expected author.email does not match result'
)
;
test
.
equals
(
expected
.
author
.
when
.
time
,
details
.
author
.
when
.
time
,
'Expected author.when.time does not match result'
)
;
test
.
equals
(
expected
.
author
.
when
.
offset
,
details
.
author
.
when
.
offset
,
'Expected author.when.offset does not match result'
)
;
test
.
equals
(
expected
.
parentCount
,
details
.
parentCount
,
'Expected parentCount does not match result'
)
;
test
.
equals
(
expected
.
parentShas
[
0
]
,
details
.
parentShas
[
0
]
,
'Expected parentShas[0] does not match result'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL