From 52e6c77c743a0f7b88f1a8f14b73bde9463f1eb4 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 20 Sep 2024 09:58:00 +0200 Subject: [PATCH] Use the new handlers when evaluating repo webhooks We added new watermill handlers that allow to refresh and evaluate a generic entity with properties. This is the first patch in a series that takes these handlers into account with the eventual goal of removing all the bespoke code from the GitHub webhook handler and eventually remove direct database access from the webhook handler. I'll expand the same method for the other webhook events we issue, but let's do small PRs so we can have some test runs in between them and revert in case of issues. Related: #4327 --- .../controlplane/handlers_githubwebhooks.go | 47 +- .../handlers_githubwebhooks_test.go | 966 +----------------- 2 files changed, 60 insertions(+), 953 deletions(-) diff --git a/internal/controlplane/handlers_githubwebhooks.go b/internal/controlplane/handlers_githubwebhooks.go index 1b0241c466..b3c08c32ec 100644 --- a/internal/controlplane/handlers_githubwebhooks.go +++ b/internal/controlplane/handlers_githubwebhooks.go @@ -40,6 +40,7 @@ import ( "github.com/stacklok/minder/internal/controlplane/metrics" "github.com/stacklok/minder/internal/db" "github.com/stacklok/minder/internal/engine/entities" + entityMessage "github.com/stacklok/minder/internal/entities/handlers/message" "github.com/stacklok/minder/internal/entities/models" "github.com/stacklok/minder/internal/entities/properties" "github.com/stacklok/minder/internal/entities/properties/service" @@ -944,29 +945,7 @@ func (s *Server) processRepositoryEvent( l.Info().Msg("handling event for repository") - repoEnt, err := s.fetchRepo(ctx, event.GetRepo()) - if err != nil { - return nil, err - } - - // protobufs are our API, so we always execute on these instead of the DB directly. - pbMsg, err := s.props.EntityWithPropertiesAsProto(ctx, repoEnt, s.providerManager) - if err != nil { - return nil, fmt.Errorf("error converting repository to protobuf: %w", err) - } - - pbRepo, ok := pbMsg.(*pb.Repository) - if !ok { - return nil, errors.New("error converting proto message to protobuf") - } - - eiw := entities.NewEntityInfoWrapper(). - WithProjectID(repoEnt.Entity.ProjectID). - WithProviderID(repoEnt.Entity.ProviderID). - WithRepository(pbRepo). - WithRepositoryID(repoEnt.Entity.ID) - - return &processingResult{topic: events.TopicQueueEntityEvaluate, wrapper: eiw}, nil + return s.sendEvaluateRepoMessage(event.GetRepo(), events.TopicQueueRefreshEntityAndEvaluate) } // nolint:gocyclo // This function will be re-simplified real soon @@ -1252,6 +1231,28 @@ func (_ *Server) repositoryAdded( }, nil } +func (_ *Server) sendEvaluateRepoMessage( + repo *repo, + handler string, +) (*processingResult, error) { + lookByProps, err := properties.NewProperties(map[string]any{ + // the PropertyUpstreamID is always a string + properties.PropertyUpstreamID: strconv.FormatInt(repo.GetID(), 10), + }) + if err != nil { + return nil, fmt.Errorf("error creating repository properties: %w", err) + } + + entRefresh := entityMessage.NewEntityRefreshAndDoMessage(). + WithEntity(pb.Entity_ENTITY_REPOSITORIES, lookByProps). + WithProviderImplementsHint(string(db.ProviderTypeGithub)) + + return &processingResult{ + topic: handler, + wrapper: entRefresh}, + nil +} + func (s *Server) fetchRepo( ctx context.Context, repo *repo, diff --git a/internal/controlplane/handlers_githubwebhooks_test.go b/internal/controlplane/handlers_githubwebhooks_test.go index 46594a3081..653434005d 100644 --- a/internal/controlplane/handlers_githubwebhooks_test.go +++ b/internal/controlplane/handlers_githubwebhooks_test.go @@ -1348,29 +1348,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1380,9 +1358,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -1399,29 +1374,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1431,9 +1384,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -1450,29 +1400,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1482,9 +1410,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -1501,29 +1426,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1533,9 +1436,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -1551,29 +1451,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1583,9 +1461,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -1602,29 +1477,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1634,9 +1487,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -1652,29 +1502,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -1684,9 +1512,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2303,29 +2128,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2335,9 +2138,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2354,29 +2154,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2386,9 +2164,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2405,29 +2180,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2437,9 +2190,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2456,29 +2206,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2488,9 +2216,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2507,29 +2232,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2539,9 +2242,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2558,29 +2258,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2590,9 +2268,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2608,29 +2283,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2640,9 +2293,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2659,29 +2309,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2691,9 +2319,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2710,29 +2335,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2742,9 +2345,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2761,29 +2361,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2793,9 +2371,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2812,29 +2387,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2844,9 +2397,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2863,29 +2413,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2895,9 +2423,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2914,29 +2439,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2946,9 +2449,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -2965,29 +2465,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -2997,9 +2475,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3016,29 +2491,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3048,9 +2501,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3067,29 +2517,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3099,9 +2527,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3117,29 +2542,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3149,9 +2552,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3167,29 +2567,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3199,9 +2577,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3228,29 +2603,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { HTMLURL: github.String("https://github.com/stacklok/minder"), }, }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3260,9 +2613,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3271,29 +2621,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { event: "push", // https://pkg.go.dev/github.com/google/go-github/v62@v62.0.0/github#PushEvent rawPayload: []byte(rawPushEvent), - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3303,9 +2631,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, @@ -3323,29 +2648,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: nil, }, @@ -3361,29 +2664,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: nil, }, @@ -3392,29 +2673,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { // https://docs.github.com/en/webhooks/webhook-events-and-payloads#branch_protection_configuration event: "branch_protection_configuration", rawPayload: []byte(rawBranchProtectionConfigurationDisabledEvent), - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3424,9 +2683,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3441,29 +2697,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3473,9 +2707,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3490,29 +2721,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3522,9 +2731,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3539,29 +2745,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3571,9 +2755,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3588,29 +2769,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3620,9 +2779,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3637,29 +2793,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3669,9 +2803,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, }, { @@ -3686,29 +2817,7 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { "https://github.com/stacklok/minder", ), }, - mockPropsBld: newPropSvcMock( - withSuccessRepoProto(), - ), - mockRepoBld: newRepoSvcMock( - withSuccessRepoById( - models.EntityInstance{ - ID: repositoryID, - Type: v1.Entity_ENTITY_REPOSITORIES, - ProviderID: providerID, - ProjectID: projectID, - }, - map[string]any{ - properties.PropertyName: "stacklok/minder", - properties.PropertyUpstreamID: "12345", - properties.RepoPropertyIsArchived: false, - properties.RepoPropertyIsPrivate: false, - properties.RepoPropertyIsFork: false, - ghprop.RepoPropertyOwner: "stacklok", - ghprop.RepoPropertyName: "minder", - ghprop.RepoPropertyId: int64(12345), - }), - ), - topic: events.TopicQueueEntityEvaluate, + topic: events.TopicQueueRefreshEntityAndEvaluate, statusCode: http.StatusOK, queued: func(t *testing.T, event string, ch <-chan *message.Message) { t.Helper() @@ -3718,9 +2827,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() { require.Equal(t, "12345", received.Metadata["id"]) require.Equal(t, event, received.Metadata["type"]) require.Equal(t, "https://api.github.com/", received.Metadata["source"]) - require.Equal(t, providerID.String(), received.Metadata["provider_id"]) - require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey]) - require.Equal(t, repositoryID.String(), received.Metadata["repository_id"]) }, },