@@ -14,6 +14,8 @@ import (
1414 ipld "github.com/ipfs/go-ipld-format"
1515)
1616
17+ var testPrefix = "test/"
18+
1719func (tp * TestSuite ) TestPin (t * testing.T ) {
1820 tp .hasApi (t , func (api iface.CoreAPI ) error {
1921 if api .Pin () == nil {
@@ -40,7 +42,7 @@ func (tp *TestSuite) TestPinAdd(t *testing.T) {
4042 t .Fatal (err )
4143 }
4244
43- err = api .Pin ().Add (ctx , p )
45+ err = api .Pin ().Add (ctx , testPrefix , p )
4446 if err != nil {
4547 t .Fatal (err )
4648 }
@@ -59,12 +61,12 @@ func (tp *TestSuite) TestPinSimple(t *testing.T) {
5961 t .Fatal (err )
6062 }
6163
62- err = api .Pin ().Add (ctx , p )
64+ err = api .Pin ().Add (ctx , testPrefix , p )
6365 if err != nil {
6466 t .Fatal (err )
6567 }
6668
67- list , err := api .Pin ().Ls (ctx )
69+ list , err := api .Pin ().Ls (ctx , testPrefix , opt . Pin . RecursiveList ( true ) )
6870 if err != nil {
6971 t .Fatal (err )
7072 }
@@ -81,12 +83,12 @@ func (tp *TestSuite) TestPinSimple(t *testing.T) {
8183 t .Error ("unexpected pin type" )
8284 }
8385
84- err = api .Pin ().Rm (ctx , p )
86+ err = api .Pin ().Rm (ctx , testPrefix + p . Cid (). String () )
8587 if err != nil {
8688 t .Fatal (err )
8789 }
8890
89- list , err = api .Pin ().Ls (ctx )
91+ list , err = api .Pin ().Ls (ctx , testPrefix , opt . Pin . RecursiveList ( true ) )
9092 if err != nil {
9193 t .Fatal (err )
9294 }
@@ -128,17 +130,17 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
128130 t .Fatal (err )
129131 }
130132
131- err = api .Pin ().Add (ctx , path .IpldPath (nd2 .Cid ()))
133+ err = api .Pin ().Add (ctx , testPrefix , path .IpldPath (nd2 .Cid ()))
132134 if err != nil {
133135 t .Fatal (err )
134136 }
135137
136- err = api .Pin ().Add (ctx , path .IpldPath (nd3 .Cid ()), opt .Pin .Recursive (false ))
138+ err = api .Pin ().Add (ctx , testPrefix , path .IpldPath (nd3 .Cid ()), opt .Pin .Recursive (false ))
137139 if err != nil {
138140 t .Fatal (err )
139141 }
140142
141- list , err := api .Pin ().Ls (ctx )
143+ list , err := api .Pin ().Ls (ctx , testPrefix , opt . Pin . RecursiveList ( true ) )
142144 if err != nil {
143145 t .Fatal (err )
144146 }
@@ -147,7 +149,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
147149 t .Errorf ("unexpected pin list len: %d" , len (list ))
148150 }
149151
150- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Direct ())
152+ list , err = api .Pin ().Ls (ctx , testPrefix , opt .Pin .Type .Direct (), opt . Pin . RecursiveList ( true ))
151153 if err != nil {
152154 t .Fatal (err )
153155 }
@@ -160,7 +162,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
160162 t .Errorf ("unexpected path, %s != %s" , list [0 ].Path ().String (), path .IpfsPath (nd2 .Cid ()).String ())
161163 }
162164
163- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Recursive ())
165+ list , err = api .Pin ().Ls (ctx , testPrefix , opt .Pin .Type .Recursive (), opt . Pin . RecursiveList ( true ))
164166 if err != nil {
165167 t .Fatal (err )
166168 }
@@ -173,7 +175,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
173175 t .Errorf ("unexpected path, %s != %s" , list [0 ].Path ().String (), path .IpldPath (nd3 .Cid ()).String ())
174176 }
175177
176- list , err = api .Pin ().Ls (ctx , opt .Pin .Type .Indirect ())
178+ list , err = api .Pin ().Ls (ctx , "" , opt .Pin .Type .Indirect (), opt . Pin . RecursiveList ( true ))
177179 if err != nil {
178180 t .Fatal (err )
179181 }
0 commit comments