The alert-org test lists another org first

The test's organizations table now answers another org for the first row,
so it fails on any code that addresses alerts to the first org rather than
the rule's own.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
zooqueen
2026-09-24 16:42:39 -07:00
co-authored by Hanzo Dev
parent 62b4ca36dc
commit b6a2a6131a
+13 -3
View File
@@ -5,7 +5,10 @@ import (
"testing"
"time"
"github.com/DATA-DOG/go-sqlmock"
"github.com/hanzoai/o11y/pkg/instrumentation/instrumentationtest"
"github.com/hanzoai/o11y/pkg/sqlstore"
"github.com/hanzoai/o11y/pkg/sqlstore/sqlstoretest"
"github.com/hanzoai/o11y/pkg/types/ruletypes"
"github.com/hanzoai/o11y/pkg/valuer"
"github.com/stretchr/testify/require"
@@ -16,10 +19,17 @@ import (
func TestSendAlertsAddressesTheRulesOrg(t *testing.T) {
orgID := valuer.GenerateUUID()
now := time.Now()
// The organizations table lists another org first.
store := sqlstoretest.New(sqlstore.Config{Provider: "sqlite"}, sqlmock.QueryMatcherRegexp)
store.Mock().ExpectQuery(`SELECT .* FROM .*organizations`).
WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(valuer.GenerateUUID().StringValue()))
r := &BaseRule{
id: "rule-1",
orgID: orgID,
logger: instrumentationtest.New().Logger(),
id: "rule-1",
orgID: orgID,
sqlstore: store,
logger: instrumentationtest.New().Logger(),
Active: map[uint64]*ruletypes.Alert{
1: {State: ruletypes.StateFiring, FiredAt: now.Add(-time.Minute)},
},