Add update client api and dialog (#164)

This commit is contained in:
GianOrtiz
2019-03-16 07:18:51 -03:00
committed by Jannis Mattheis
parent efcf4ad13d
commit e32359ed15
11 changed files with 318 additions and 5 deletions

View File

@@ -38,3 +38,8 @@ func (d *GormDatabase) GetClientsByUser(userID uint) []*model.Client {
func (d *GormDatabase) DeleteClientByID(id uint) error {
return d.DB.Where("id = ?", id).Delete(&model.Client{}).Error
}
// UpdateClient updates a client.
func (d *GormDatabase) UpdateClient(client *model.Client) error {
return d.DB.Save(client).Error
}

View File

@@ -29,6 +29,11 @@ func (s *DatabaseSuite) TestClient() {
newClient = s.db.GetClientByToken(client.Token)
assert.Equal(s.T(), client, newClient)
updateClient := &model.Client{ID: client.ID, UserID: user.ID, Token: "C0000000000", Name: "new_name"}
s.db.UpdateClient(updateClient)
updatedClient := s.db.GetClientByID(client.ID)
assert.Equal(s.T(), updateClient, updatedClient)
s.db.DeleteClientByID(client.ID)
clients = s.db.GetClientsByUser(user.ID)