FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/raw-error.js at v0.0.1 · 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-error.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (51 loc) · 1.9 KB
Breadcrumbs
nodegit
/
test
/
raw-error.js
Copy path
File metadata and controls
64 lines (51 loc) · 1.9 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
var
git
=
require
(
'../'
)
.
raw
,
rimraf
=
require
(
'../vendor/rimraf'
)
||
require
(
'rimraf'
)
;
// 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
)
;
}
}
}
;
// Error
exports
.
constructor
=
function
(
test
)
{
test
.
expect
(
3
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
git
.
Error
,
'Error'
)
;
// Ensure we get an instance of Error
test
.
ok
(
new
git
.
Error
(
)
instanceof
git
.
Error
,
'Invocation returns an instance of Error'
)
;
test
.
done
(
)
;
}
;
// Error::StrError
exports
.
str_error
=
function
(
test
)
{
var
testError
=
new
git
.
Error
(
)
;
test
.
expect
(
6
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testError
.
strError
,
'Error::StrError'
)
;
// Test path argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testError
.
strError
(
)
;
}
,
'Throw an exception if no error code'
)
;
// Test that arguments result correctly
helper
.
testException
(
test
.
ifError
,
function
(
)
{
testError
.
strError
(
0
)
;
}
,
'No exception is thrown with proper arguments'
)
;
// Finding an actual error
test
.
equals
(
'Input was not a properly formatted Git object id.'
,
testError
.
strError
(
-
2
)
,
'Returns proper error message per code.'
)
;
// Returning a consistent error message for all unknown errors
test
.
equals
(
'Unknown error'
,
testError
.
strError
(
1000
)
,
'Returns consistent error message with an unknown.'
)
;
test
.
done
(
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL