@@ -14,6 +14,8 @@ import (
14
14
ipld "github.com/ipfs/go-ipld-format"
15
15
)
16
16
17
+ var testPrefix = "test/"
18
+
17
19
func (tp * TestSuite ) TestPin (t * testing.T ) {
18
20
tp .hasApi (t , func (api iface.CoreAPI ) error {
19
21
if api .Pin () == nil {
@@ -40,7 +42,7 @@ func (tp *TestSuite) TestPinAdd(t *testing.T) {
40
42
t .Fatal (err )
41
43
}
42
44
43
- err = api .Pin ().Add (ctx , p )
45
+ err = api .Pin ().Add (ctx , testPrefix , p )
44
46
if err != nil {
45
47
t .Fatal (err )
46
48
}
@@ -59,12 +61,12 @@ func (tp *TestSuite) TestPinSimple(t *testing.T) {
59
61
t .Fatal (err )
60
62
}
61
63
62
- err = api .Pin ().Add (ctx , p )
64
+ err = api .Pin ().Add (ctx , testPrefix , p )
63
65
if err != nil {
64
66
t .Fatal (err )
65
67
}
66
68
67
- list , err := api .Pin ().Ls (ctx )
69
+ list , err := api .Pin ().Ls (ctx , testPrefix , opt . Pin . RecursiveList ( true ) )
68
70
if err != nil {
69
71
t .Fatal (err )
70
72
}
@@ -81,12 +83,12 @@ func (tp *TestSuite) TestPinSimple(t *testing.T) {
81
83
t .Error ("unexpected pin type" )
82
84
}
83
85
84
- err = api .Pin ().Rm (ctx , p )
86
+ err = api .Pin ().Rm (ctx , testPrefix + p . Cid (). String () )
85
87
if err != nil {
86
88
t .Fatal (err )
87
89
}
88
90
89
- list , err = api .Pin ().Ls (ctx )
91
+ list , err = api .Pin ().Ls (ctx , testPrefix , opt . Pin . RecursiveList ( true ) )
90
92
if err != nil {
91
93
t .Fatal (err )
92
94
}
@@ -128,17 +130,17 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
128
130
t .Fatal (err )
129
131
}
130
132
131
- err = api .Pin ().Add (ctx , path .IpldPath (nd2 .Cid ()))
133
+ err = api .Pin ().Add (ctx , testPrefix , path .IpldPath (nd2 .Cid ()))
132
134
if err != nil {
133
135
t .Fatal (err )
134
136
}
135
137
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 ))
137
139
if err != nil {
138
140
t .Fatal (err )
139
141
}
140
142
141
- list , err := api .Pin ().Ls (ctx )
143
+ list , err := api .Pin ().Ls (ctx , testPrefix , opt . Pin . RecursiveList ( true ) )
142
144
if err != nil {
143
145
t .Fatal (err )
144
146
}
@@ -147,7 +149,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
147
149
t .Errorf ("unexpected pin list len: %d" , len (list ))
148
150
}
149
151
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 ))
151
153
if err != nil {
152
154
t .Fatal (err )
153
155
}
@@ -160,7 +162,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
160
162
t .Errorf ("unexpected path, %s != %s" , list [0 ].Path ().String (), path .IpfsPath (nd2 .Cid ()).String ())
161
163
}
162
164
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 ))
164
166
if err != nil {
165
167
t .Fatal (err )
166
168
}
@@ -173,7 +175,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
173
175
t .Errorf ("unexpected path, %s != %s" , list [0 ].Path ().String (), path .IpldPath (nd3 .Cid ()).String ())
174
176
}
175
177
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 ))
177
179
if err != nil {
178
180
t .Fatal (err )
179
181
}
0 commit comments