From 8b789adc353780b4a6688e8d2b3e8f47e60bf487 Mon Sep 17 00:00:00 2001 From: niukuo Date: Fri, 22 Mar 2019 16:32:01 +0800 Subject: add Repository.CreateRemoteAnonymous Signed-off-by: niukuo --- repository_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'repository_test.go') diff --git a/repository_test.go b/repository_test.go index 1549737..ccbe29b 100644 --- a/repository_test.go +++ b/repository_test.go @@ -231,6 +231,36 @@ func (s *RepositorySuite) TestCreateRemoteInvalid(c *C) { c.Assert(remote, IsNil) } +func (s *RepositorySuite) TestCreateRemoteAnonymous(c *C) { + r, _ := Init(memory.NewStorage(), nil) + remote, err := r.CreateRemoteAnonymous(&config.RemoteConfig{ + Name: "anonymous", + URLs: []string{"http://foo/foo.git"}, + }) + + c.Assert(err, IsNil) + c.Assert(remote.Config().Name, Equals, "anonymous") +} + +func (s *RepositorySuite) TestCreateRemoteAnonymousInvalidName(c *C) { + r, _ := Init(memory.NewStorage(), nil) + remote, err := r.CreateRemoteAnonymous(&config.RemoteConfig{ + Name: "not_anonymous", + URLs: []string{"http://foo/foo.git"}, + }) + + c.Assert(err, Equals, ErrAnonymousRemoteName) + c.Assert(remote, IsNil) +} + +func (s *RepositorySuite) TestCreateRemoteAnonymousInvalid(c *C) { + r, _ := Init(memory.NewStorage(), nil) + remote, err := r.CreateRemoteAnonymous(&config.RemoteConfig{}) + + c.Assert(err, Equals, config.ErrRemoteConfigEmptyName) + c.Assert(remote, IsNil) +} + func (s *RepositorySuite) TestDeleteRemote(c *C) { r, _ := Init(memory.NewStorage(), nil) _, err := r.CreateRemote(&config.RemoteConfig{ -- cgit