Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
gandalftest: handle git urls in the repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Souza committed Feb 10, 2015
1 parent 534d076 commit fd26753
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gandalftest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
3 changes: 3 additions & 0 deletions gandalftest/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand All @@ -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) {
Expand Down

0 comments on commit fd26753

Please sign in to comment.