Skip to content

Commit

Permalink
Add test for allowing to close a command when the client is already c…
Browse files Browse the repository at this point in the history
…losed

This test is for issue go-git#70
  • Loading branch information
dcu committed Mar 26, 2021
1 parent 3e3eda0 commit 1f2daa6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions plumbing/transport/ssh/common_test.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/kevinburke/ssh_config"
"golang.org/x/crypto/ssh"
stdssh "golang.org/x/crypto/ssh"
. "gopkg.in/check.v1"
)

Expand Down Expand Up @@ -93,6 +94,26 @@ func (s *SuiteCommon) TestDefaultSSHConfigWildcard(c *C) {
c.Assert(cmd.getHostWithPort(), Equals, "github.com:22")
}

func (s *SuiteCommon) TestIssue70(c *C) {
uploadPack := &UploadPackSuite{}
uploadPack.SetUpSuite(c)

config := &ssh.ClientConfig{
HostKeyCallback: stdssh.InsecureIgnoreHostKey(),
}
r := &runner{
config: config,
}

cmd, err := r.Command("command", uploadPack.newEndpoint(c, "endpoint"), uploadPack.EmptyAuth)
c.Assert(err, IsNil)

c.Assert(cmd.(*command).client.Close(), IsNil)

err = cmd.Close()
c.Assert(err, IsNil)
}

type mockSSHConfig struct {
Values map[string]map[string]string
}
Expand Down

0 comments on commit 1f2daa6

Please sign in to comment.