FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/test/raw-repo.js at v0.0.77 · 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-repo.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (101 loc) · 3.3 KB
Breadcrumbs
nodegit
/
test
/
raw-repo.js
Copy path
File metadata and controls
126 lines (101 loc) · 3.3 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
var
git
=
require
(
'../'
)
.
raw
,
rimraf
=
require
(
'rimraf'
)
,
path
=
require
(
'path'
)
,
fs
=
require
(
'fs'
)
;
// 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
)
;
}
}
}
;
// Repo
exports
.
constructor
=
function
(
test
)
{
test
.
expect
(
3
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
git
.
Repo
,
'Repo'
)
;
// Ensure we get an instance of Repo
test
.
ok
(
new
git
.
Repo
(
)
instanceof
git
.
Repo
,
'Invocation returns an instance of Repo'
)
;
test
.
done
(
)
;
}
;
// Repo::Open
exports
.
open
=
function
(
test
)
{
var
testRepo
=
new
git
.
Repo
(
)
;
test
.
expect
(
6
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testRepo
.
open
,
'Repo::Open'
)
;
// Test path argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testRepo
.
open
(
)
;
}
,
'Throw an exception if no path'
)
;
// Test callback argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testRepo
.
open
(
'some/path'
)
;
}
,
'Throw an exception if no callback'
)
;
// Test invalid repository
testRepo
.
open
(
'/etc/hosts'
,
function
(
error
)
{
test
.
equals
(
git
.
Error
.
codes
.
GIT_ERROR
,
error
.
klass
,
'Invalid repository error code'
)
;
// Test valid repository
testRepo
.
open
(
path
.
resolve
(
'../.git'
)
,
function
(
error
)
{
test
.
equals
(
null
,
error
,
'Valid repository error code'
)
;
test
.
done
(
)
;
}
)
;
}
)
;
}
;
// TODO: Figure out how write unit tests for free
// Repo::Free
exports
.
free
=
function
(
test
)
{
var
testRepo
=
new
git
.
Repo
(
)
;
test
.
expect
(
2
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testRepo
.
free
,
'Repo::Free'
)
;
test
.
done
(
)
;
}
;
// Repo::Init
exports
.
init
=
function
(
test
)
{
var
testRepo
=
new
git
.
Repo
(
)
;
test
.
expect
(
7
)
;
// Test for function
helper
.
testFunction
(
test
.
equals
,
testRepo
.
init
,
'Repo::Init'
)
;
// Test path argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testRepo
.
init
(
)
;
}
,
'Throw an exception if no path'
)
;
// Test is_bare argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testRepo
.
init
(
"some/path"
)
;
}
,
'Throw an exception if no is_bare'
)
;
// Test callback argument existence
helper
.
testException
(
test
.
ok
,
function
(
)
{
testRepo
.
init
(
"some/path"
,
true
)
;
}
,
'Throw an exception if no callback'
)
;
// Cleanup, remove test repo directory - if it exists
rimraf
(
'./test.git'
,
function
(
)
{
// Create bare repo and test for creation
testRepo
.
init
(
'./test.git'
,
true
,
function
(
error
,
path
,
is_bare
)
{
test
.
equals
(
null
,
error
,
'Successfully created bare repository'
)
;
// Verify repo exists
testRepo
.
open
(
'./test.git'
,
function
(
error
,
path
)
{
test
.
equals
(
null
,
error
,
'Valid repository created'
)
;
testRepo
.
free
(
)
;
// Cleanup, remove test repo directory
rimraf
(
'./test.git'
,
function
(
)
{
test
.
done
(
)
;
}
)
;
}
)
;
}
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL