Refactor: Change sqlstore.inTransaction to .WithTransactionalDBSession (#43245)

* Refactor: Change sqlstore.inTransaction(...) to SQLStore.WithTransactionalDBSession(...) in alert_notification.go

* Chore: Fix BE lint err

* fix: fix failing sqlstore nil error

* chore: remove unecessary setup()

* fix: use appropriate ctx
This commit is contained in:
Katarina Yang
2022-01-06 18:21:39 +01:00
committed by GitHub
parent 846c6ce758
commit 7f8daa0eae
2 changed files with 38 additions and 36 deletions
@@ -20,8 +20,7 @@ import (
func TestAlertNotificationSQLAccess(t *testing.T) {
var sqlStore *SQLStore
setup := func() {
sqlStore := InitTestDB(t)
sqlStore = InitTestDB(t)
// Set up bus handlers
bus.AddHandler("deleteAlertNotification", func(ctx context.Context, cmd *models.DeleteAlertNotificationCommand) error {
return sqlStore.DeleteAlertNotification(ctx, cmd)
@@ -181,7 +180,6 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
t.Run("invalid frequency", func(t *testing.T) {
cmd.Frequency = "invalid duration"
err := sqlStore.CreateAlertNotificationCommand(context.Background(), cmd)
require.True(t, regexp.MustCompile(`^time: invalid duration "?invalid duration"?$`).MatchString(
err.Error()))