Tests to check Timeout is for an update
License: MIT Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
This commit is contained in:
parent
3e61377f86
commit
96d230a195
|
@ -423,7 +423,7 @@ func (ipfs *Connector) refsProgress(ctx context.Context, hash cid.Cid, maxDepth
|
|||
|
||||
// We have a Ref!
|
||||
if errStr := ref.Err; errStr != "" {
|
||||
return errors.New(errStr)
|
||||
logger.Error(errStr)
|
||||
}
|
||||
|
||||
select { // do not lock
|
||||
|
|
|
@ -94,6 +94,26 @@ func testPin(t *testing.T, method string) {
|
|||
if err == nil {
|
||||
t.Error("expected error pinning cid")
|
||||
}
|
||||
|
||||
if method == "refs" {
|
||||
ipfs.config.PinTimeout = 1 * time.Second
|
||||
c3 := test.SlowCid1
|
||||
err = ipfs.Pin(ctx, c3, -1)
|
||||
if err == nil {
|
||||
t.Error("expected error pinning cid")
|
||||
}
|
||||
fmt.Println("SlowCid1 " + err.Error())
|
||||
}
|
||||
|
||||
if method == "pin" {
|
||||
ipfs.config.PinTimeout = 5 * time.Second
|
||||
c4 := test.SlowCid1
|
||||
err = ipfs.Pin(ctx, c4, -1)
|
||||
if err == nil {
|
||||
t.Error("expected error pinning cid")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestIPFSPin(t *testing.T) {
|
||||
|
|
|
@ -169,7 +169,14 @@ func (m *IpfsMock) handler(w http.ResponseWriter, r *http.Request) {
|
|||
Pins: []string{arg},
|
||||
}
|
||||
j, _ := json.Marshal(resp)
|
||||
w.Write(j)
|
||||
if c.Equals(SlowCid1) {
|
||||
for i := 0; i <= 10; i++ {
|
||||
time.Sleep(1 * time.Second)
|
||||
w.Write(j)
|
||||
}
|
||||
} else {
|
||||
w.Write(j)
|
||||
}
|
||||
case "pin/rm":
|
||||
arg, ok := extractCid(r.URL)
|
||||
if !ok {
|
||||
|
@ -339,7 +346,14 @@ func (m *IpfsMock) handler(w http.ResponseWriter, r *http.Request) {
|
|||
Ref: arg,
|
||||
}
|
||||
j, _ := json.Marshal(resp)
|
||||
w.Write(j)
|
||||
if arg == SlowCid1.String() {
|
||||
for i := 0; i <= 5; i++ {
|
||||
time.Sleep(2 * time.Second)
|
||||
w.Write(j)
|
||||
}
|
||||
} else {
|
||||
w.Write(j)
|
||||
}
|
||||
case "version":
|
||||
w.Write([]byte("{\"Version\":\"m.o.c.k\"}"))
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue
Block a user