summaryrefslogtreecommitdiff
path: root/remote_test.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2021-09-05 16:39:07 -0700
committerGitHub <[email protected]>2021-09-05 16:39:07 -0700
commitb983e1daebf528443e2a3954cd595fa3664ec93f (patch)
tree51ed7f7c359c9548dad7afa1a445749380d59f66 /remote_test.go
parentf1fa96c7b7f548389c7560d3a1a0bce83be56c9f (diff)
Add support for managed HTTP/S transports (#810)
This change uses the newly-exposed Transport interface to use Go's implementation of http.Client instead of httpclient via libgit2.
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go
index 7e37274..9660a3f 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/rand"
"crypto/rsa"
+ "errors"
"fmt"
"io"
"net"
@@ -232,6 +233,31 @@ func TestRemotePrune(t *testing.T) {
}
}
+func TestRemoteCredentialsCalled(t *testing.T) {
+ t.Parallel()
+
+ repo := createTestRepo(t)
+ defer cleanupTestRepo(t, repo)
+
+ remote, err := repo.Remotes.CreateAnonymous("https://github.com/libgit2/non-existent")
+ checkFatal(t, err)
+ defer remote.Free()
+
+ errNonExistent := errors.New("non-existent repository")
+ fetchOpts := FetchOptions{
+ RemoteCallbacks: RemoteCallbacks{
+ CredentialsCallback: func(url, username string, allowedTypes CredentialType) (*Credential, error) {
+ return nil, errNonExistent
+ },
+ },
+ }
+
+ err = remote.Fetch(nil, &fetchOpts, "fetch")
+ if err != errNonExistent {
+ t.Fatalf("remote.Fetch() = %v, want %v", err, errNonExistent)
+ }
+}
+
func newChannelPipe(t *testing.T, w io.Writer, wg *sync.WaitGroup) (*os.File, error) {
pr, pw, err := os.Pipe()
if err != nil {