@@ -914,6 +914,7 @@ func TestAccessReviewCampaignSource_NameSurvivesSourceDeletion(t *testing.T) {
|
|||||||
orgID := owner.GetOrganizationID().String()
|
orgID := owner.GetOrganizationID().String()
|
||||||
|
|
||||||
const snapshotName = "Archived Snapshot Source"
|
const snapshotName = "Archived Snapshot Source"
|
||||||
|
|
||||||
sourceID := factory.NewAccessReviewSource(owner, orgID).
|
sourceID := factory.NewAccessReviewSource(owner, orgID).
|
||||||
WithName(snapshotName).
|
WithName(snapshotName).
|
||||||
WithCsvData(testCsvData).
|
WithCsvData(testCsvData).
|
||||||
|
|||||||
@@ -590,6 +590,7 @@ func (s *Service) CountFetchAttemptsForCampaignSourceID(
|
|||||||
var attempts coredata.AccessReviewCampaignSourceFetchAttempts
|
var attempts coredata.AccessReviewCampaignSourceFetchAttempts
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
count, err = attempts.CountByCampaignSourceID(ctx, conn, scope, campaignSourceID)
|
count, err = attempts.CountByCampaignSourceID(ctx, conn, scope, campaignSourceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot count fetch attempts: %w", err)
|
return fmt.Errorf("cannot count fetch attempts: %w", err)
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ func (s *Service) RecordDecisions(
|
|||||||
decidedByID, ok := decidedByCache[entry.OrganizationID]
|
decidedByID, ok := decidedByCache[entry.OrganizationID]
|
||||||
if !ok {
|
if !ok {
|
||||||
decidedByID = nil
|
decidedByID = nil
|
||||||
|
|
||||||
if d.DecidedByID != nil {
|
if d.DecidedByID != nil {
|
||||||
profile := &coredata.MembershipProfile{}
|
profile := &coredata.MembershipProfile{}
|
||||||
if err := profile.LoadByIdentityIDAndOrganizationID(ctx, conn, scope, *d.DecidedByID, entry.OrganizationID); err == nil {
|
if err := profile.LoadByIdentityIDAndOrganizationID(ctx, conn, scope, *d.DecidedByID, entry.OrganizationID); err == nil {
|
||||||
|
|||||||
@@ -439,6 +439,7 @@ WHERE status = 'FETCHING'
|
|||||||
AND updated_at < @stale_threshold
|
AND updated_at < @stale_threshold
|
||||||
FOR UPDATE SKIP LOCKED
|
FOR UPDATE SKIP LOCKED
|
||||||
`
|
`
|
||||||
|
|
||||||
rows, err := conn.Query(ctx, q, pgx.StrictNamedArgs{"stale_threshold": staleThreshold})
|
rows, err := conn.Query(ctx, q, pgx.StrictNamedArgs{"stale_threshold": staleThreshold})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("cannot query stale fetch attempts: %w", err)
|
return 0, fmt.Errorf("cannot query stale fetch attempts: %w", err)
|
||||||
|
|||||||
@@ -80,12 +80,14 @@ func TestAccessReviewSourceDeletion_PreservesSnapshotAndEntries(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
loadedEntry := &coredata.AccessReviewEntry{}
|
loadedEntry := &coredata.AccessReviewEntry{}
|
||||||
|
|
||||||
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||||
return loadedEntry.LoadByID(ctx, conn, fx.scope, entryID)
|
return loadedEntry.LoadByID(ctx, conn, fx.scope, entryID)
|
||||||
}))
|
}))
|
||||||
assert.Equal(t, "preserve-me@example.com", loadedEntry.Email, "entry must survive source deletion")
|
assert.Equal(t, "preserve-me@example.com", loadedEntry.Email, "entry must survive source deletion")
|
||||||
|
|
||||||
loadedSource := &coredata.AccessReviewCampaignSource{}
|
loadedSource := &coredata.AccessReviewCampaignSource{}
|
||||||
|
|
||||||
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||||
return loadedSource.LoadByID(ctx, conn, fx.scope, fx.campaignSourceID)
|
return loadedSource.LoadByID(ctx, conn, fx.scope, fx.campaignSourceID)
|
||||||
}))
|
}))
|
||||||
@@ -137,6 +139,7 @@ func TestSourceFetchAttempts_AppendOnly(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
var history coredata.AccessReviewCampaignSourceFetchAttempts
|
var history coredata.AccessReviewCampaignSourceFetchAttempts
|
||||||
|
|
||||||
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||||
return history.LoadAllByCampaignSourceID(ctx, conn, fx.scope, fx.campaignSourceID)
|
return history.LoadAllByCampaignSourceID(ctx, conn, fx.scope, fx.campaignSourceID)
|
||||||
}))
|
}))
|
||||||
@@ -147,6 +150,7 @@ func TestSourceFetchAttempts_AppendOnly(t *testing.T) {
|
|||||||
assert.Equal(t, failureMsg, *history[1].Error, "the failed attempt's error is retained")
|
assert.Equal(t, failureMsg, *history[1].Error, "the failed attempt's error is retained")
|
||||||
|
|
||||||
var latest coredata.AccessReviewCampaignSourceFetchAttempts
|
var latest coredata.AccessReviewCampaignSourceFetchAttempts
|
||||||
|
|
||||||
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
require.NoError(t, client.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||||
return latest.LoadLatestByCampaignID(ctx, conn, fx.scope, fx.campaignID)
|
return latest.LoadLatestByCampaignID(ctx, conn, fx.scope, fx.campaignID)
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user