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

Commit

Permalink
Merge pull request #141 from rfloriano/master
Browse files Browse the repository at this point in the history
Modified parameters for the route archive to be passed by querystring
  • Loading branch information
andrewsmedina committed Jul 30, 2014
2 parents d829aa1 + 2885406 commit 2352c86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ func GetFileContents(w http.ResponseWriter, r *http.Request) {

func GetArchive(w http.ResponseWriter, r *http.Request) {
repo := r.URL.Query().Get(":name")
ref := r.URL.Query().Get(":ref")
format := r.URL.Query().Get(":format")
ref := r.URL.Query().Get("ref")
format := r.URL.Query().Get("format")
if ref == "" || format == "" || repo == "" {
err := fmt.Errorf("Error when trying to obtain archive for ref '%s' (format: %s) of repository '%s' (repository, ref and format are required).", ref, format, repo)
http.Error(w, err.Error(), http.StatusBadRequest)
Expand Down
10 changes: 5 additions & 5 deletions api/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ func (s *S) TestGetFileContentsWhenNoRepository(c *gocheck.C) {
}

func (s *S) TestGetArchiveWhenNoRef(c *gocheck.C) {
url := "/repository/repo/archive/.zip?:name=repo&:ref=&:format=zip"
url := "/repository/repo/archive?:name=repo&ref=&format=zip"
request, err := http.NewRequest("GET", url, nil)
c.Assert(err, gocheck.IsNil)
recorder := httptest.NewRecorder()
Expand All @@ -778,7 +778,7 @@ func (s *S) TestGetArchiveWhenNoRef(c *gocheck.C) {
}

func (s *S) TestGetArchiveWhenNoRepo(c *gocheck.C) {
url := "/repository//archive/master.zip?:name=&:ref=master&:format=zip"
url := "/repository//archive?:name=&ref=master&format=zip"
request, err := http.NewRequest("GET", url, nil)
c.Assert(err, gocheck.IsNil)
recorder := httptest.NewRecorder()
Expand All @@ -789,7 +789,7 @@ func (s *S) TestGetArchiveWhenNoRepo(c *gocheck.C) {
}

func (s *S) TestGetArchiveWhenNoFormat(c *gocheck.C) {
url := "/repository/repo/archive/master.?:name=repo&:ref=master&:format="
url := "/repository/repo/archive?:name=repo&ref=master&format="
request, err := http.NewRequest("GET", url, nil)
c.Assert(err, gocheck.IsNil)
recorder := httptest.NewRecorder()
Expand All @@ -800,7 +800,7 @@ func (s *S) TestGetArchiveWhenNoFormat(c *gocheck.C) {
}

func (s *S) TestGetArchiveWhenCommandFails(c *gocheck.C) {
url := "/repository/repo/archive/master.zip?:name=repo&:ref=master&:format=zip"
url := "/repository/repo/archive?:name=repo&ref=master&format=zip"
expected := fmt.Errorf("output error")
mockRetriever := repository.MockContentRetriever{
OutputError: expected,
Expand All @@ -818,7 +818,7 @@ func (s *S) TestGetArchiveWhenCommandFails(c *gocheck.C) {
}

func (s *S) TestGetArchive(c *gocheck.C) {
url := "/repository/repo/archive/master.zip?:name=repo&:ref=master&:format=zip"
url := "/repository/repo/archive?:name=repo&ref=master&format=zip"
expected := "result123"
mockRetriever := repository.MockContentRetriever{
ResultContents: []byte(expected),
Expand Down
2 changes: 1 addition & 1 deletion webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ For an example conf check gandalf/etc/gandalf.conf file.\n %s`
router.Del("/repository/:name", http.HandlerFunc(api.RemoveRepository))
router.Get("/repository/:name", http.HandlerFunc(api.GetRepository))
router.Put("/repository/:name", http.HandlerFunc(api.RenameRepository))
router.Get("/repository/:name/archive/:ref.:format", http.HandlerFunc(api.GetArchive))
router.Get("/repository/:name/archive", http.HandlerFunc(api.GetArchive))
router.Get("/repository/:name/contents", http.HandlerFunc(api.GetFileContents))
router.Get("/repository/:name/tree/:path", http.HandlerFunc(api.GetTree))
router.Get("/repository/:name/tree", http.HandlerFunc(api.GetTree))
Expand Down

0 comments on commit 2352c86

Please sign in to comment.