@@ -67,7 +67,7 @@ func (tp *TestSuite) TestPinSimple(t *testing.T) {
67
67
t .Fatal (err )
68
68
}
69
69
70
- list , err := api .Pin ().Ls (ctx )
70
+ list , err := accPins ( api .Pin ().Ls (ctx ) )
71
71
if err != nil {
72
72
t .Fatal (err )
73
73
}
@@ -89,7 +89,7 @@ func (tp *TestSuite) TestPinSimple(t *testing.T) {
89
89
t .Fatal (err )
90
90
}
91
91
92
- list , err = api .Pin ().Ls (ctx )
92
+ list , err = accPins ( api .Pin ().Ls (ctx ) )
93
93
if err != nil {
94
94
t .Fatal (err )
95
95
}
@@ -141,7 +141,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
141
141
t .Fatal (err )
142
142
}
143
143
144
- list , err := api .Pin ().Ls (ctx )
144
+ list , err := accPins ( api .Pin ().Ls (ctx ) )
145
145
if err != nil {
146
146
t .Fatal (err )
147
147
}
@@ -150,7 +150,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
150
150
t .Errorf ("unexpected pin list len: %d" , len (list ))
151
151
}
152
152
153
- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Direct ())
153
+ list , err = accPins ( api .Pin ().Ls (ctx , opt .Pin .Ls .Direct () ))
154
154
if err != nil {
155
155
t .Fatal (err )
156
156
}
@@ -163,7 +163,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
163
163
t .Errorf ("unexpected path, %s != %s" , list [0 ].Path ().String (), path .IpfsPath (nd2 .Cid ()).String ())
164
164
}
165
165
166
- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Recursive ())
166
+ list , err = accPins ( api .Pin ().Ls (ctx , opt .Pin .Ls .Recursive () ))
167
167
if err != nil {
168
168
t .Fatal (err )
169
169
}
@@ -176,7 +176,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
176
176
t .Errorf ("unexpected path, %s != %s" , list [0 ].Path ().String (), path .IpldPath (nd3 .Cid ()).String ())
177
177
}
178
178
179
- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Indirect ())
179
+ list , err = accPins ( api .Pin ().Ls (ctx , opt .Pin .Ls .Indirect () ))
180
180
if err != nil {
181
181
t .Fatal (err )
182
182
}
@@ -390,21 +390,21 @@ func getThreeChainedNodes(t *testing.T, ctx context.Context, api iface.CoreAPI,
390
390
func assertPinTypes (t * testing.T , ctx context.Context , api iface.CoreAPI , recusive , direct , indirect []cidContainer ) {
391
391
assertPinLsAllConsistency (t , ctx , api )
392
392
393
- list , err := api .Pin ().Ls (ctx , opt .Pin .Type .Recursive ())
393
+ list , err := accPins ( api .Pin ().Ls (ctx , opt .Pin .Ls .Recursive () ))
394
394
if err != nil {
395
395
t .Fatal (err )
396
396
}
397
397
398
398
assertPinCids (t , list , recusive ... )
399
399
400
- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Direct ())
400
+ list , err = accPins ( api .Pin ().Ls (ctx , opt .Pin .Ls .Direct () ))
401
401
if err != nil {
402
402
t .Fatal (err )
403
403
}
404
404
405
405
assertPinCids (t , list , direct ... )
406
406
407
- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Indirect ())
407
+ list , err = accPins ( api .Pin ().Ls (ctx , opt .Pin .Ls .Indirect () ))
408
408
if err != nil {
409
409
t .Fatal (err )
410
410
}
@@ -454,7 +454,7 @@ func assertPinCids(t *testing.T, pins []iface.Pin, cids ...cidContainer) {
454
454
// assertPinLsAllConsistency verifies that listing all pins gives the same result as listing the pin types individually
455
455
func assertPinLsAllConsistency (t * testing.T , ctx context.Context , api iface.CoreAPI ) {
456
456
t .Helper ()
457
- allPins , err := api .Pin ().Ls (ctx )
457
+ allPins , err := accPins ( api .Pin ().Ls (ctx ) )
458
458
if err != nil {
459
459
t .Fatal (err )
460
460
}
@@ -485,7 +485,7 @@ func assertPinLsAllConsistency(t *testing.T, ctx context.Context, api iface.Core
485
485
}
486
486
487
487
for typeStr , pinProps := range typeMap {
488
- pins , err := api .Pin ().Ls (ctx , pinProps .PinLsOption )
488
+ pins , err := accPins ( api .Pin ().Ls (ctx , pinProps .PinLsOption ) )
489
489
if err != nil {
490
490
t .Fatal (err )
491
491
}
@@ -505,3 +505,20 @@ func assertPinLsAllConsistency(t *testing.T, ctx context.Context, api iface.Core
505
505
}
506
506
}
507
507
}
508
+
509
+ func accPins (pins <- chan iface.Pin , err error ) ([]iface.Pin , error ) {
510
+ if err != nil {
511
+ return nil , err
512
+ }
513
+
514
+ var result []iface.Pin
515
+
516
+ for pin := range pins {
517
+ if pin .Err () != nil {
518
+ return nil , pin .Err ()
519
+ }
520
+ result = append (result , pin )
521
+ }
522
+
523
+ return result , nil
524
+ }
0 commit comments