@@ -31,25 +31,18 @@ module.exports = (createCommon, options) => {
31
31
32
32
function populate ( ) {
33
33
series ( [
34
- cb => { // two files wrapped in a directory, root CID pinned recursively
34
+ // two files wrapped in directories, only root CID pinned recursively
35
+ cb => {
35
36
const dir = fixtures . directory . files . map ( ( file ) => ( { path : file . path , content : file . data } ) )
36
- ipfs . files . add ( dir , { pin : false } , ( err , res ) => {
37
- if ( err ) return cb ( err )
38
- ipfs . pin . add ( fixtures . directory . cid , { recursive : true } , cb )
39
- } )
37
+ ipfs . add ( dir , { pin : false , cidVersion : 0 } , cb )
40
38
} ,
41
- cb => { // a file (CID pinned recursively)
42
- ipfs . files . add ( fixtures . files [ 0 ] . data , { pin : false } , ( err , res ) => {
43
- if ( err ) return cb ( err )
44
- ipfs . pin . add ( fixtures . files [ 0 ] . cid , { recursive : true } , cb )
45
- } )
46
- } ,
47
- cb => { // a single CID (pinned directly)
48
- ipfs . files . add ( fixtures . files [ 1 ] . data , { pin : false } , ( err , res ) => {
49
- if ( err ) return cb ( err )
50
- ipfs . pin . add ( fixtures . files [ 1 ] . cid , { recursive : false } , cb )
51
- } )
52
- }
39
+ cb => ipfs . pin . add ( fixtures . directory . cid , { recursive : true } , cb ) ,
40
+ // a file (CID pinned recursively)
41
+ cb => ipfs . add ( fixtures . files [ 0 ] . data , { pin : false , cidVersion : 0 } , cb ) ,
42
+ cb => ipfs . pin . add ( fixtures . files [ 0 ] . cid , { recursive : true } , cb ) ,
43
+ // a single CID (pinned directly)
44
+ cb => ipfs . add ( fixtures . files [ 1 ] . data , { pin : false , cidVersion : 0 } , cb ) ,
45
+ cb => ipfs . pin . add ( fixtures . files [ 1 ] . cid , { recursive : false } , cb )
53
46
] , done )
54
47
}
55
48
} )
@@ -87,6 +80,14 @@ module.exports = (createCommon, options) => {
87
80
type : 'recursive' ,
88
81
hash : fixtures . directory . cid
89
82
} )
83
+ expect ( pinset ) . to . deep . include ( {
84
+ type : 'indirect' ,
85
+ hash : fixtures . directory . files [ 0 ] . cid
86
+ } )
87
+ expect ( pinset ) . to . deep . include ( {
88
+ type : 'indirect' ,
89
+ hash : fixtures . directory . files [ 1 ] . cid
90
+ } )
90
91
done ( )
91
92
} )
92
93
} )
@@ -95,7 +96,6 @@ module.exports = (createCommon, options) => {
95
96
ipfs . pin . ls ( ( err , pinset ) => {
96
97
expect ( err ) . to . not . exist ( )
97
98
expect ( pinset ) . to . not . be . empty ( )
98
- expect ( pinset ) . to . have . lengthOf ( 15 )
99
99
// check the three "roots"
100
100
expect ( pinset ) . to . deep . include ( {
101
101
type : 'recursive' ,
@@ -109,6 +109,14 @@ module.exports = (createCommon, options) => {
109
109
type : 'direct' ,
110
110
hash : fixtures . files [ 1 ] . cid
111
111
} )
112
+ expect ( pinset ) . to . deep . include ( {
113
+ type : 'indirect' ,
114
+ hash : fixtures . directory . files [ 0 ] . cid
115
+ } )
116
+ expect ( pinset ) . to . deep . include ( {
117
+ type : 'indirect' ,
118
+ hash : fixtures . directory . files [ 1 ] . cid
119
+ } )
112
120
done ( )
113
121
} )
114
122
} )
@@ -117,7 +125,6 @@ module.exports = (createCommon, options) => {
117
125
return ipfs . pin . ls ( )
118
126
. then ( ( pinset ) => {
119
127
expect ( pinset ) . to . not . be . empty ( )
120
- expect ( pinset ) . to . have . lengthOf ( 15 )
121
128
// check our three "roots"
122
129
expect ( pinset ) . to . deep . include ( {
123
130
type : 'recursive' ,
@@ -131,12 +138,21 @@ module.exports = (createCommon, options) => {
131
138
type : 'direct' ,
132
139
hash : fixtures . files [ 1 ] . cid
133
140
} )
141
+ expect ( pinset ) . to . deep . include ( {
142
+ type : 'indirect' ,
143
+ hash : fixtures . directory . files [ 0 ] . cid
144
+ } )
145
+ expect ( pinset ) . to . deep . include ( {
146
+ type : 'indirect' ,
147
+ hash : fixtures . directory . files [ 1 ] . cid
148
+ } )
134
149
} )
135
150
} )
136
151
137
152
it ( 'should list all direct pins' , ( done ) => {
138
153
ipfs . pin . ls ( { type : 'direct' } , ( err , pinset ) => {
139
154
expect ( err ) . to . not . exist ( )
155
+ expect ( pinset ) . to . have . lengthOf ( 1 )
140
156
expect ( pinset ) . to . deep . include ( {
141
157
type : 'direct' ,
142
158
hash : fixtures . files [ 1 ] . cid
@@ -166,21 +182,21 @@ module.exports = (createCommon, options) => {
166
182
} )
167
183
} )
168
184
169
- it ( 'should throw an error on missing direct pins for a specific path' , ( done ) => {
170
- // alice .txt is an indirect pin, so lookup for direct one should throw an error
185
+ it ( 'should throw an error on missing direct pins for existing path' , ( done ) => {
186
+ // ipfs .txt is an indirect pin, so lookup for direct one should throw an error
171
187
ipfs . pin . ls ( `/ipfs/${ fixtures . directory . cid } /files/ipfs.txt` , { type : 'direct' } , ( err , pinset ) => {
188
+ expect ( err ) . to . exist ( )
172
189
expect ( pinset ) . to . not . exist ( )
173
- expect ( err ) . to . not . be . empty ( )
174
190
expect ( err . message ) . to . be . equal ( `path '/ipfs/${ fixtures . directory . cid } /files/ipfs.txt' is not pinned` )
175
191
done ( )
176
192
} )
177
193
} )
178
194
179
195
it ( 'should throw an error on missing link for a specific path' , ( done ) => {
180
196
ipfs . pin . ls ( `/ipfs/${ fixtures . directory . cid } /I-DONT-EXIST.txt` , { type : 'direct' } , ( err , pinset ) => {
197
+ expect ( err ) . to . exist ( )
181
198
expect ( pinset ) . to . not . exist ( )
182
- expect ( err ) . to . not . be . empty ( )
183
- expect ( err . message ) . to . be . equal ( 'no link by that name' )
199
+ expect ( err . message ) . to . be . equal ( `no link named "I-DONT-EXIST.txt" under ${ fixtures . directory . cid } ` )
184
200
done ( )
185
201
} )
186
202
} )
0 commit comments