コード例 #1
0
func (s *SuiteRemote) TestDisconnect(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	c.Assert(r.Disconnect(), IsNil)
	c.Assert(r.connected, Equals, false)
}
コード例 #2
0
func (s *SuiteRemote) TestConnectWithPublicKeysCallback(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService()
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()
	c.Assert(r.connected, Equals, true)
	c.Assert(r.auth, Equals, agent.auth)
}
コード例 #3
0
func (s *SuiteRemote) TestCapabilities(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()

	info, err := r.Info()
	c.Assert(err, IsNil)
	c.Assert(info.Capabilities.Get("agent").Values, HasLen, 1)
}
コード例 #4
0
func (s *SuiteRemote) TestDefaultBranch(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()

	info, err := r.Info()
	c.Assert(err, IsNil)
	c.Assert(info.Capabilities.SymbolicReference("HEAD"), Equals, "refs/heads/master")
}
コード例 #5
0
func (s *SuiteRemote) TestFetch(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()

	pr := &common.GitUploadPackRequest{}
	pr.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
	reader, err := r.Fetch(pr)
	c.Assert(err, IsNil)

	b, err := ioutil.ReadAll(reader)
	c.Assert(err, IsNil)
	c.Assert(b, HasLen, 85374)
}