Folders: Fix failure to update folder in SQLite (#81795)

This commit is contained in:
Sofia Papagiannaki 2024-02-05 10:06:11 +02:00 committed by GitHub
parent 8175b31e16
commit ec5bc7c4ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 1 deletions

View File

@ -610,7 +610,7 @@ func (s *Service) Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (
namespace, id := cmd.SignedInUser.GetNamespacedID()
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Folder).Inc()
if err := s.bus.Publish(context.Background(), &events.FolderTitleUpdated{
if err := s.bus.Publish(ctx, &events.FolderTitleUpdated{
Timestamp: foldr.Updated,
Title: foldr.Title,
ID: dashFolder.ID, // nolint:staticcheck

View File

@ -25,6 +25,42 @@ import (
const orgID = 1
func TestIntegrationUpdateFolder(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
DisableAnonymous: true,
EnableQuota: true,
})
grafanaListedAddr, store := testinfra.StartGrafana(t, dir, path)
// Create user
createUser(t, store, user.CreateUserCommand{
DefaultOrgRole: string(org.RoleAdmin),
Password: "admin",
Login: "admin",
})
adminClient := tests.GetClient(grafanaListedAddr, "admin", "admin")
resp, err := adminClient.Folders.CreateFolder(&models.CreateFolderCommand{
Title: "folder",
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.Code())
t.Run("update folder should succeed", func(t *testing.T) {
resp, err := adminClient.Folders.UpdateFolder(resp.Payload.UID, &models.UpdateFolderCommand{
Title: "new title",
Version: resp.Payload.Version,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.Code())
require.Equal(t, "new title", resp.Payload.Title)
})
}
func TestIntegrationCreateFolder(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")