Replace AddHandler with AddHandlerCtx in tests (#42585)

This commit is contained in:
idafurjes
2021-12-01 15:43:31 +01:00
committed by GitHub
parent 2e3fd9d659
commit e6123bc3ef
37 changed files with 173 additions and 162 deletions
@@ -283,7 +283,7 @@ func setupDeleteHandlers(t *testing.T, fakeStore *fakeDashboardStore, provisione
}
result := &Result{}
bus.AddHandler("test", func(cmd *models.DeleteDashboardCommand) error {
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.DeleteDashboardCommand) error {
require.Equal(t, cmd.Id, int64(1))
require.Equal(t, cmd.OrgId, int64(1))
result.deleteWasCalled = true
@@ -25,7 +25,7 @@ func TestFolderService(t *testing.T) {
origNewGuardian := guardian.New
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{})
bus.AddHandler("test", func(query *models.GetDashboardQuery) error {
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.GetDashboardQuery) error {
query.Result = models.NewDashboardFolder("Folder")
return nil
})
@@ -85,7 +85,7 @@ func TestFolderService(t *testing.T) {
dash := models.NewDashboardFolder("Folder")
dash.Id = 1
bus.AddHandler("test", func(query *models.GetDashboardQuery) error {
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.GetDashboardQuery) error {
query.Result = dash
return nil
})
@@ -99,12 +99,12 @@ func TestFolderService(t *testing.T) {
return nil
}
bus.AddHandler("test", func(cmd *models.SaveDashboardCommand) error {
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.SaveDashboardCommand) error {
cmd.Result = dash
return nil
})
bus.AddHandler("test", func(cmd *models.DeleteDashboardCommand) error {
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.DeleteDashboardCommand) error {
return nil
})
@@ -139,7 +139,7 @@ func TestFolderService(t *testing.T) {
dashFolder.Id = 1
dashFolder.Uid = "uid-abc"
bus.AddHandler("test", func(query *models.GetDashboardQuery) error {
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.GetDashboardQuery) error {
query.Result = dashFolder
return nil
})