Skip to content

Commit c480125

Browse files
committed
testL add TestParsingError
1 parent bfe19d2 commit c480125

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cid_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
crand "crypto/rand"
66
"encoding/json"
7+
"errors"
78
"fmt"
89
"io"
910
"math/rand"
@@ -763,3 +764,15 @@ func TestLoggable(t *testing.T) {
763764
t.Fatalf("did not get expected loggable form (got %v)", actual)
764765
}
765766
}
767+
768+
func TestParsingError(t *testing.T) {
769+
_, err := Decode("not-a-cid")
770+
if err == nil {
771+
t.Fatal("expected error")
772+
}
773+
774+
is := errors.Is(err, &ErrInvalidCid{})
775+
if !is {
776+
t.Fatal("expected error to be ErrInvalidCid")
777+
}
778+
}

0 commit comments

Comments
 (0)