aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorandrew2nelson <andrew2nelson@arista.com>2020-09-02 13:38:42 -0700
committerandrew2nelson <andrew2nelson@arista.com>2020-09-02 13:45:28 -0700
commit9d7bd4d4bded83428a39dda358eef19e98e42f23 (patch)
treee21f7e24a11118e2f8eda4884ddcb1cdff030144 /remote_test.go
parent6da5e5958ecc0e6f8da6ee2b6714e50b8ef26df4 (diff)
downloadgo-git-9d7bd4d4bded83428a39dda358eef19e98e42f23.tar.gz
Fetch should return a unique error type when ref not found
It can be useful for callers to distinguish between an error of "couldn't find remote ref" and some other error like "network error". Creating an explicit error type for this allows consumers to determine the kind of error using the errors.Is and errors.As interface added in go1.13
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go
index c6ea9ea..3446f1a 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -3,6 +3,7 @@ package git
import (
"bytes"
"context"
+ "errors"
"io"
"io/ioutil"
"os"
@@ -145,6 +146,7 @@ func (s *RemoteSuite) TestFetchNonExistantReference(c *C) {
})
c.Assert(err, ErrorMatches, "couldn't find remote ref.*")
+ c.Assert(errors.Is(err, NoMatchingRefSpecError{}), Equals, true)
}
func (s *RemoteSuite) TestFetchContext(c *C) {