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

Commit

Permalink
Repository Update now doesn`t updates the name
Browse files Browse the repository at this point in the history
The repository Rename opeartion does not updates a
repository data. In fact, it deletes and add another
one cause the name is the mongo _id, and a update on
_id is not possible on mongo. It`s also renames
the repository in filesystem.

This job is responsability of the Rename handler/repository
methods.
  • Loading branch information
ricardodani committed Sep 16, 2014
1 parent b6edc9b commit c7dacc9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
18 changes: 0 additions & 18 deletions api/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,24 +908,6 @@ func (s *S) TestUpdateRespositoryShouldReturnErrorWhenBodyIsEmpty(c *gocheck.C)
c.Assert(recorder.Code, gocheck.Equals, 400)
}

func (s *S) TestUpdateRepositoryName(c *gocheck.C) {
r, err := repository.New("raising", []string{"guardian@what.com"}, []string{""}, true)
c.Assert(err, gocheck.IsNil)
url := fmt.Sprintf("/repository/%s/update", r.Name)
body := strings.NewReader(`{"name":"freedom"}`)
request, err := http.NewRequest("PUT", url, body)
c.Assert(err, gocheck.IsNil)
recorder := httptest.NewRecorder()
s.router.ServeHTTP(recorder, request)
c.Assert(recorder.Code, gocheck.Equals, http.StatusOK)
_, err = repository.Get("raising")
c.Assert(err, gocheck.NotNil)
r.Name = "freedom"
repo, err := repository.Get("freedom")
c.Assert(err, gocheck.IsNil)
c.Assert(repo, gocheck.DeepEquals, *r)
}

func (s *S) TestUpdateRepositoryData(c *gocheck.C) {
r, err := repository.New("something", []string{"guardian@what.com"}, []string{""}, true)
c.Assert(err, gocheck.IsNil)
Expand Down
7 changes: 0 additions & 7 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ func Update(name string, newData Repository) error {
log.Errorf("repository.Update: Repository %q not found: %s", name, err)
return err
}
if newName := newData.Name; len(newName) > 0 && newName != repo.Name {
err = Rename(name, newName)
if err != nil {
return err
}
repo.Name = newName
}
d := bson.M{}
if !reflect.DeepEqual(newData.Users, repo.Users) {
d["users"] = newData.Users
Expand Down
4 changes: 2 additions & 2 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ func (s *S) TestUpdate(c *gocheck.C) {
fs.Fsystem = rfs
defer func() { fs.Fsystem = nil }()
expected := Repository{
Name: "freedom2",
Name: "freedom",
Users: []string{"a", "b"},
ReadOnlyUsers: []string{"c", "d"},
IsPublic: true,
}
err = Update(r.Name, expected)
c.Assert(err, gocheck.IsNil)
repo, err := Get("freedom2")
repo, err := Get("freedom")
c.Assert(err, gocheck.IsNil)
c.Assert(repo, gocheck.DeepEquals, expected)
}
Expand Down

0 comments on commit c7dacc9

Please sign in to comment.