Skip to content

Commit

Permalink
revert testsendmessage
Browse files Browse the repository at this point in the history
  • Loading branch information
eternal-flame-AD committed Jul 28, 2023
1 parent 168c03c commit ead566d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
2 changes: 1 addition & 1 deletion database/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (d *GormDatabase) UpdateClient(client *model.Client) error {
return d.DB.Save(client).Error
}

// UpdateClientTokensLastUsed updates the last used timestamp of clients
// UpdateClientTokensLastUsed updates the last used timestamp of clients.
func (d *GormDatabase) UpdateClientTokensLastUsed(tokens []string, t *time.Time) error {
return d.DB.Model(&model.Client{}).Where("token IN (?)", tokens).Update("last_used", t).Error
}
31 changes: 0 additions & 31 deletions router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,30 +336,12 @@ func (s *IntegrationSuite) TestSendMessage() {
json.NewDecoder(res.Body).Decode(token)
assert.Equal(s.T(), "backup-server", token.Name)

req = s.newRequest("POST", "client", `{"name": "mock-client"}`)
req.SetBasicAuth("admin", "pw")
res, err = client.Do(req)
assert.Nil(s.T(), err)
assert.Equal(s.T(), 200, res.StatusCode)
ct := &model.Client{}
json.NewDecoder(res.Body).Decode(ct)
assert.Equal(s.T(), "mock-client", ct.Name)
assert.Nil(s.T(), ct.LastUsed)

conn := s.connectWebSocket(fmt.Sprintf("stream?token=%s", ct.Token))
defer conn.Close()

req = s.newRequest("POST", "message", `{"message": "backup done", "title": "backup done"}`)
req.Header.Add("X-Gotify-Key", token.Token)
res, err = client.Do(req)
assert.Nil(s.T(), err)
assert.Equal(s.T(), 200, res.StatusCode)

msgThruWs := &model.MessageExternal{}
assert.Nil(s.T(), conn.ReadJSON(msgThruWs))
assert.Equal(s.T(), "backup done", msgThruWs.Message)
assert.Equal(s.T(), "backup done", msgThruWs.Title)

req = s.newRequest("GET", "message", "")
req.SetBasicAuth("admin", "pw")
res, err = client.Do(req)
Expand All @@ -370,23 +352,10 @@ func (s *IntegrationSuite) TestSendMessage() {
assert.Len(s.T(), msgs.Messages, 1)

msg := msgs.Messages[0]
assert.Equal(s.T(), msgThruWs, msg)
assert.Equal(s.T(), "backup done", msg.Message)
assert.Equal(s.T(), "backup done", msg.Title)
assert.Equal(s.T(), uint(1), msg.ID)
assert.Equal(s.T(), token.ID, msg.ApplicationID)

var clients []*model.Client
req = s.newRequest("GET", "client", "")
req.SetBasicAuth("admin", "pw")
res, err = client.Do(req)
assert.Nil(s.T(), err)
assert.Equal(s.T(), 200, res.StatusCode)
json.NewDecoder(res.Body).Decode(&clients)
assert.Len(s.T(), clients, 1)
assert.Equal(s.T(), "mock-client", clients[0].Name)
assert.Equal(s.T(), uint(1), clients[0].ID)
assert.NotNil(s.T(), clients[0].LastUsed)
}

func (s *IntegrationSuite) TestPluginLoadFail_expectPanic() {
Expand Down

0 comments on commit ead566d

Please sign in to comment.