Skip to content

Commit

Permalink
testL add TestParsingError
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Mar 16, 2023
1 parent bfe19d2 commit c480125
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cid_test.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
crand "crypto/rand"
"encoding/json"
"errors"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -763,3 +764,15 @@ func TestLoggable(t *testing.T) {
t.Fatalf("did not get expected loggable form (got %v)", actual)
}
}

func TestParsingError(t *testing.T) {
_, err := Decode("not-a-cid")
if err == nil {
t.Fatal("expected error")
}

is := errors.Is(err, &ErrInvalidCid{})
if !is {
t.Fatal("expected error to be ErrInvalidCid")
}
}

0 comments on commit c480125

Please sign in to comment.