@@ -9,10 +9,11 @@ const expect = chai.expect
9
9
chai . use ( dirtyChai )
10
10
const loadFixture = require ( 'aegir/fixtures' )
11
11
12
- const testfile = loadFixture ( __dirname , '../test/fixtures/testfile.txt' , 'interface-ipfs-core' )
12
+ const testFile = loadFixture ( __dirname , '../test/fixtures/testfile.txt' , 'interface-ipfs-core' )
13
+ const testHash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
13
14
14
15
module . exports = ( common ) => {
15
- describe ( '.pin' , function ( ) {
16
+ describe . only ( '.pin' , function ( ) {
16
17
this . timeout ( 50 * 1000 )
17
18
18
19
let ipfs
@@ -28,14 +29,12 @@ module.exports = (common) => {
28
29
} )
29
30
30
31
function populate ( ) {
31
- const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
32
32
33
- ipfs . files . add ( testfile , ( err , res ) => {
33
+ ipfs . files . add ( testFile , ( err , res ) => {
34
34
expect ( err ) . to . not . exist ( )
35
-
36
35
expect ( res ) . to . have . length ( 1 )
37
- expect ( res [ 0 ] . hash ) . to . equal ( expectedMultihash )
38
- expect ( res [ 0 ] . path ) . to . equal ( expectedMultihash )
36
+ expect ( res [ 0 ] . hash ) . to . equal ( testHash )
37
+ expect ( res [ 0 ] . path ) . to . equal ( testHash )
39
38
done ( )
40
39
} )
41
40
}
@@ -47,26 +46,49 @@ module.exports = (common) => {
47
46
48
47
describe ( 'callback API' , ( ) => {
49
48
// 1st, because ipfs.files.add pins automatically
50
- it ( '.rm' , ( done ) => {
51
- const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
49
+ it ( '.ls type recursive' , ( done ) => {
50
+ ipfs . pin . ls ( { type : 'recursive' } , ( err , pinset ) => {
51
+ expect ( err ) . to . not . exist ( )
52
+ expect ( pinset ) . to . deep . include ( {
53
+ hash : testHash ,
54
+ type : 'recursive'
55
+ } )
56
+ done ( )
57
+ } )
58
+ } )
52
59
53
- ipfs . pin . rm ( hash , { recursive : true } , ( err , pinset ) => {
60
+ // it('.ls type indirect', (done) => {
61
+ // ipfs.pin.ls({ type: 'indirect' }, (err, pinset) => {
62
+ // expect(err).to.not.exist()
63
+ // // because the pinned file has no links
64
+ // expect(pinset).to.be.empty()
65
+ // done()
66
+ // })
67
+ // })
68
+
69
+ it ( '.rm' , ( done ) => {
70
+ ipfs . pin . rm ( testHash , { recursive : true } , ( err , pinset ) => {
54
71
expect ( err ) . to . not . exist ( )
55
- expect ( pinset ) . to . exist ( )
72
+ expect ( pinset ) . to . deep . equal ( [ {
73
+ hash : testHash
74
+ } ] )
56
75
ipfs . pin . ls ( { type : 'direct' } , ( err , pinset ) => {
57
76
expect ( err ) . to . not . exist ( )
58
- expect ( pinset ) . to . be . empty ( )
77
+ expect ( pinset ) . to . not . deep . include ( {
78
+ hash : testHash ,
79
+ type : 'recursive'
80
+ } )
59
81
done ( )
60
82
} )
61
83
} )
62
84
} )
63
85
64
86
it ( '.add' , ( done ) => {
65
- const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
66
-
67
- ipfs . pin . add ( hash , { recursive : false } , ( err , pinset ) => {
87
+ ipfs . pin . add ( testHash , { recursive : false } , ( err , pinset ) => {
68
88
expect ( err ) . to . not . exist ( )
69
- expect ( pinset [ 0 ] ) . to . be . equal ( hash )
89
+ expect ( pinset ) . to . deep . equal ( [ {
90
+ hash : testHash
91
+ } ] )
70
92
done ( )
71
93
} )
72
94
} )
@@ -75,81 +97,79 @@ module.exports = (common) => {
75
97
ipfs . pin . ls ( ( err , pinset ) => {
76
98
expect ( err ) . to . not . exist ( )
77
99
expect ( pinset ) . to . not . be . empty ( )
100
+ expect ( pinset ) . to . deep . include ( {
101
+ hash : testHash ,
102
+ type : 'direct'
103
+ } )
78
104
done ( )
79
105
} )
80
106
} )
81
107
82
108
it ( '.ls type direct' , ( done ) => {
83
109
ipfs . pin . ls ( { type : 'direct' } , ( err , pinset ) => {
84
110
expect ( err ) . to . not . exist ( )
85
- expect ( pinset ) . to . not . be . empty ( )
86
- done ( )
87
- } )
88
- } )
89
-
90
- it ( '.ls type indirect' , ( done ) => {
91
- ipfs . pin . ls ( { type : 'indirect' } , ( err , pinset ) => {
92
- expect ( err ) . to . not . exist ( )
93
- expect ( pinset ) . to . not . be . empty ( )
94
- done ( )
95
- } )
96
- } )
97
-
98
- it ( '.ls type recursive' , ( done ) => {
99
- ipfs . pin . ls ( { type : 'recursive' } , ( err , pinset ) => {
100
- expect ( err ) . to . not . exist ( )
101
- expect ( pinset ) . to . not . be . empty ( )
111
+ expect ( pinset ) . to . deep . include ( {
112
+ hash : testHash ,
113
+ type : 'direct'
114
+ } )
102
115
done ( )
103
116
} )
104
117
} )
105
118
106
119
it ( '.ls for a specific hash' , ( done ) => {
107
- const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
108
-
109
- ipfs . pin . ls ( hash , ( err , pinset ) => {
120
+ ipfs . pin . ls ( testHash , ( err , pinset ) => {
110
121
expect ( err ) . to . not . exist ( )
111
- expect ( pinset ) . to . exist ( )
122
+ expect ( pinset ) . to . deep . equal ( [ {
123
+ hash : testHash ,
124
+ type : 'direct'
125
+ } ] )
112
126
done ( )
113
127
} )
114
128
} )
115
129
} )
116
130
117
131
describe ( 'promise API' , ( ) => {
118
132
it ( '.add' , ( ) => {
119
- const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
120
-
121
- return ipfs . pin . add ( hash , { recursive : false } )
133
+ return ipfs . pin . add ( testHash , { recursive : false } )
122
134
. then ( ( pinset ) => {
123
- expect ( pinset [ 0 ] ) . to . be . equal ( hash )
135
+ expect ( pinset ) . to . deep . equal ( [ {
136
+ hash : testHash
137
+ } ] )
124
138
} )
125
139
} )
126
140
127
141
it ( '.ls' , ( ) => {
128
142
return ipfs . pin . ls ( )
129
143
. then ( ( pinset ) => {
130
- expect ( pinset ) . to . exist ( )
131
- expect ( pinset ) . to . not . be . empty ( )
144
+ expect ( pinset ) . to . deep . include ( {
145
+ hash : testHash ,
146
+ type : 'direct'
147
+ } )
132
148
} )
133
149
} )
134
150
135
151
it ( '.ls hash' , ( ) => {
136
- const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
137
-
138
- return ipfs . pin . ls ( hash )
152
+ return ipfs . pin . ls ( testHash )
139
153
. then ( ( pinset ) => {
140
- expect ( pinset ) . to . exist ( )
154
+ expect ( pinset ) . to . deep . equal ( [ {
155
+ hash : testHash ,
156
+ type : 'direct'
157
+ } ] )
141
158
} )
142
159
} )
143
160
144
161
it ( '.rm' , ( ) => {
145
- const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
146
-
147
- return ipfs . pin . rm ( hash , { recursive : false } )
162
+ return ipfs . pin . rm ( testHash , { recursive : false } )
148
163
. then ( ( pinset ) => {
164
+ expect ( pinset ) . to . deep . equal ( [ {
165
+ hash : testHash
166
+ } ] )
149
167
return ipfs . pin . ls ( { type : 'direct' } )
150
168
} )
151
169
. then ( ( pinset ) => {
152
- expect ( pinset ) . to . be . empty ( )
170
+ expect ( pinset ) . to . not . deep . include ( {
171
+ hash : testHash
172
+ } )
153
173
} )
154
174
} )
155
175
} )
0 commit comments