FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/raw-blob.js at v0.0.73 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
23
(23)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
test
/
raw-blob.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
173 lines (131 loc) · 4.23 KB
Breadcrumbs
nodegit
/
test
/
raw-blob.js
Copy path
File metadata and controls
173 lines (131 loc) · 4.23 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
var
git
=
require
(
'../'
)
.
raw
,
path
=
require
(
'path'
)
,
rimraf
=
require
(
'rimraf'
)
;
var
testRepo
=
new
git
.
Repo
(
)
;
// Helper functions
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
)
;
}
}
}
;
// Blob
exports
.
constructor
=
function
(
test
)
{
test
.
expect
(
3
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
git
.
Blob
,
'Blob'
)
;
// Ensure we get an instance of Blob
test
.
ok
(
new
git
.
Blob
(
)
instanceof
git
.
Blob
,
'Invocation returns an instance of Blob'
)
;
test
.
done
(
)
;
}
;
// Blob::Lookup
exports
.
lookup
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testRef
=
new
git
.
Ref
(
testRepo
)
,
testBlob
=
new
git
.
Blob
(
)
;
test
.
expect
(
5
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testBlob
.
lookup
,
'Blob::Lookup'
)
;
// Test repo argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testBlob
.
lookup
(
)
;
}
,
'Throw an exception if no repo Object'
)
;
// Test Oid argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testBlob
.
lookup
(
testRepo
)
;
}
,
'Throw an exception if no oid Object'
)
;
// Test Callback argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testBlob
.
lookup
(
testRepo
,
testOid
)
;
}
,
'Throw an exception if no callback Object'
)
;
testRepo
.
open
(
path
.
resolve
(
'../.git'
)
,
function
(
)
{
//testOid.mkstr('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5');
//testCommit.lookup(testRepo, testOid, function(err) {
// var tree = new git.Tree(testRepo)
// , entry = new git.TreeEntry()
// , blob = new git.Blob(testRepo);
// if(!testCommit.tree(tree) && tree.entryCount() > 1) {
// tree.entryByIndex(entry, 1);
// entry.toObject(testRepo, blob);
// //console.log(entry.name() + ':');
// //console.log(blob.rawSize());
// //console.dir(blob.rawContent());
// }
//});
test
.
done
(
)
;
}
)
;
}
;
// Blob::RawContent
exports
.
rawContent
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testBlob
=
new
git
.
Blob
(
)
,
testCommit
=
new
git
.
Commit
(
)
;
test
.
expect
(
2
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testBlob
.
rawContent
,
'Blob::RawContent'
)
;
testRepo
.
open
(
path
.
resolve
(
'../.git'
)
,
function
(
)
{
testOid
.
mkstr
(
'59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5'
)
;
testCommit
.
lookup
(
testRepo
,
testOid
,
function
(
err
)
{
var
tree
=
new
git
.
Tree
(
testRepo
)
,
entry
=
new
git
.
TreeEntry
(
)
,
blob
=
new
git
.
Blob
(
testRepo
)
;
//if(!testCommit.tree(tree) && tree.entryCount() > 1) {
// tree.entryByIndex(entry, 1);
// entry.toObject(testRepo, blob);
// //console.log(entry.name() + ':');
// //console.log(blob.rawSize());
// //console.dir(blob.rawContent());
//}
}
)
;
}
)
;
test
.
done
(
)
;
}
;
// Blob::RawSize
exports
.
rawSize
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testBlob
=
new
git
.
Blob
(
)
;
test
.
expect
(
2
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testBlob
.
rawSize
,
'Blob::RawSize'
)
;
test
.
done
(
)
;
}
;
// Blob::Close
exports
.
close
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testBlob
=
new
git
.
Blob
(
)
;
test
.
expect
(
2
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testBlob
.
close
,
'Blob::Close'
)
;
test
.
done
(
)
;
}
;
// Blob::CreateFromFile
exports
.
createFromFile
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testBlob
=
new
git
.
Blob
(
)
;
test
.
expect
(
2
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testBlob
.
createFromFile
,
'Blob::Close'
)
;
test
.
done
(
)
;
}
;
// Blob::CreateFromBuffer
exports
.
createFromBuffer
=
function
(
test
)
{
var
testOid
=
new
git
.
Oid
(
)
,
testBlob
=
new
git
.
Blob
(
)
;
test
.
expect
(
2
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testBlob
.
createFromBuffer
,
'Blob::CreateFromBuffer'
)
;
test
.
done
(
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL