Skip to content

Commit

Permalink
updating issue_handler_events.go + test
Browse files Browse the repository at this point in the history
  • Loading branch information
dustindemmerle committed Dec 2, 2024
1 parent 0460cb7 commit f2c0767
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/samber/lo v1.47.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.10.0
github.com/vektah/gqlparser/v2 v2.5.19
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
)
Expand Down Expand Up @@ -85,7 +86,6 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/vektah/gqlparser/v2 v2.5.19 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
Expand Down
11 changes: 9 additions & 2 deletions internal/app/issue/issue_handler_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package issue
import (
"time"

"github.com/cloudoperators/heureka/internal/app/common"
"github.com/cloudoperators/heureka/internal/app/event"
"github.com/cloudoperators/heureka/internal/app/shared"
"github.com/cloudoperators/heureka/internal/database"
Expand Down Expand Up @@ -169,12 +170,18 @@ func createIssueMatches(
continue
}

user, err := common.GetCurrentUserId(db)
if err != nil {
l.WithField("event-step", "GetCurrentUserId").WithError(err).Error("Error while getting current user ID")
continue
}

// Create new issue match
issue_match := &entity.IssueMatch{
Metadata: entity.Metadata{
CreatedBy: 1,
CreatedBy: user,
},
UserId: 1,
UserId: user,
Status: entity.IssueMatchStatusValuesNew,
Severity: issueVariantMap[issueId].Severity, //we got two simply take the first one
ComponentInstanceId: componentInstanceId,
Expand Down
1 change: 1 addition & 0 deletions internal/app/issue/issue_handler_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var _ = Describe("OnComponentVersionAttachmentToIssue", Label("app", "ComponentV
ComponentInstanceId: componentInstance.Id,
IssueId: issueEntity.Id,
}
db.On("GetAllUserIds", mock.Anything).Return([]int64{1}, nil)
db.On("CreateIssueMatch", matchIssueMatch(expectedMatch)).Return(expectedMatch, nil)

// Emit event
Expand Down

0 comments on commit f2c0767

Please sign in to comment.