diff --git a/gandalftest/server.go b/gandalftest/server.go index 2867bfc..9120467 100644 --- a/gandalftest/server.go +++ b/gandalftest/server.go @@ -47,6 +47,9 @@ type Failure struct { // GandalfServer is a fake gandalf server. An instance of the client can be // pointed to the address generated for this server type GandalfServer struct { + // Host is used for building repositories URLs. + Host string + listener net.Listener muxer *pat.Router users []string @@ -214,6 +217,8 @@ func (s *GandalfServer) createRepository(w http.ResponseWriter, r *http.Request) return } } + repo.ReadOnlyURL = fmt.Sprintf("git://%s/%s.git", s.Host, repo.Name) + repo.ReadWriteURL = fmt.Sprintf("git@%s:%s.git", s.Host, repo.Name) s.repos = append(s.repos, repo) } diff --git a/gandalftest/server_test.go b/gandalftest/server_test.go index 564c56f..bc688cd 100644 --- a/gandalftest/server_test.go +++ b/gandalftest/server_test.go @@ -159,6 +159,7 @@ func (s *S) TestCreateRepository(c *check.C) { server, err := NewServer("127.0.0.1:0") c.Assert(err, check.IsNil) defer server.Stop() + server.Host = "localhost" server.users = []string{"user1", "user2", "user3"} recorder := httptest.NewRecorder() body := strings.NewReader(`{"Name":"myrepo","Users":["user1","user2"],"ReadOnlyUsers":["user3"],"IsPublic":true}`) @@ -170,6 +171,8 @@ func (s *S) TestCreateRepository(c *check.C) { c.Assert(server.repos[0].Users, check.DeepEquals, []string{"user1", "user2"}) c.Assert(server.repos[0].ReadOnlyUsers, check.DeepEquals, []string{"user3"}) c.Assert(server.repos[0].IsPublic, check.Equals, true) + c.Assert(server.repos[0].ReadOnlyURL, check.Equals, "git://localhost/myrepo.git") + c.Assert(server.repos[0].ReadWriteURL, check.Equals, "git@localhost:myrepo.git") } func (s *S) TestCreateRepositoryDuplicateName(c *check.C) {