mirror of
https://github.com/gotify/server.git
synced 2026-07-01 00:44:18 +08:00
Add update client api and dialog (#164)
This commit is contained in:
committed by
Jannis Mattheis
parent
efcf4ad13d
commit
e32359ed15
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user