Skip to content

Commit

Permalink
Final
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkrzyz committed Oct 23, 2024
1 parent f4ab534 commit 353848a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/api/graphql/graph/baseResolver/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ func GetListOptions(requestedFields []string) *entity.ListOptions {
return &entity.ListOptions{
ShowTotalCount: lo.Contains(requestedFields, "totalCount"),
ShowPageInfo: lo.Contains(requestedFields, "pageInfo"),
IncludeAggregations: lo.Contains(requestedFields, "edges.node.metadata"),
IncludeAggregations: lo.Contains(requestedFields, "edges.node.issueMetadata"),
}
}
1 change: 1 addition & 0 deletions internal/api/graphql/graph/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func NewIssueWithAggregations(issue *entity.IssueResult) Issue {
ID: fmt.Sprintf("%d", issue.Issue.Id),
PrimaryName: &issue.Issue.PrimaryName,
Type: &issueType,
Description: &issue.Issue.Description,
LastModified: &lastModified,
IssueMetadata: &issueMetadata,
Metadata: getModelMetadata(issue.Issue.Metadata),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ query ($filter: IssueFilter, $first: Int, $after: String) {
edges {
node {
id
type
primaryName
type
description
lastModified
metadata {
created_at
created_by
Expand Down
2 changes: 1 addition & 1 deletion internal/e2e/common/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func QueryCreateIssue(port string, issue Issue) *model.Issue {
str := string(b)
req := graphql.NewRequest(str)

req.Var("input", map[string]interface{}{
req.Var("input", map[string]string{
"primaryName": issue.PrimaryName,
"description": issue.Description,
"type": issue.Type,
Expand Down
1 change: 1 addition & 0 deletions internal/e2e/common/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

const NumberOfSystemUsers = 1
const SystemUserId = 1
const EmptyUserId = -1

var SystemUserName = "systemuser"
var SystemUserUniqueUserId = "S0000000"
Expand Down
14 changes: 6 additions & 8 deletions internal/e2e/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ const (
)

var (
testCreatedIssueType = entity.IssueTypeVulnerability.String()
testUpdatedIssueType = entity.IssueTypePolicyViolation.String()
testCreatedIssueType = entity.IssueTypeVulnerability.String()
testUpdatedIssueType = entity.IssueTypePolicyViolation.String()
)

func createTestIssue(port string) string {
issue := e2e_common.QueryCreateIssue(port, e2e_common.Issue{PrimaryName: testIssuePrimaryName, Description: testCreatedIssueDescription, Type: testCreatedIssueType})
Expect(*issue.PrimaryName).To(Equal(testIssuePrimaryName))
Expect(*issue.Description).To(Equal(testCreatedIssueDescription))
Expect(issue.Type.String()).To(Equal(testCreatedIssueType))
fmt.Println("AAAAAAAAAAAAAAAAAA ", *issue)
return issue.ID
}
func updateTestIssue(port string, iid string) {
Expand All @@ -48,7 +47,6 @@ func updateTestIssue(port string, iid string) {
func getTestIssue(port string) model.Issue {
issues := e2e_common.QueryGetIssue(port, testIssuePrimaryName)
Expect(issues.TotalCount).To(Equal(1))
fmt.Println("AAAAAAAAAAAAAAAAAA ", *issues.Edges[0].Node)
return *issues.Edges[0].Node
}

Expand Down Expand Up @@ -81,13 +79,13 @@ var _ = Describe("Creating and updating entity via API", Label("e2e", "Entities"
Expect(issue.Type.String()).To(Equal(testCreatedIssueType))

Expect(issue.Metadata).To(Not(BeNil()))
Expect(*issue.Metadata.CreatedBy).To(Equal(e2e_common.SystemUserId))
Expect(*issue.Metadata.CreatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.SystemUserId)))

createdAt, err := time.Parse(dbDateLayout, *issue.Metadata.CreatedAt)
Expect(err).Should(BeNil())
Expect(createdAt).Should(BeTemporally("~", time.Now().UTC(), 3*time.Second))

Expect(*issue.Metadata.UpdatedBy).To(BeEmpty())
Expect(*issue.Metadata.UpdatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.EmptyUserId)))

updatedAt, err := time.Parse(dbDateLayout, *issue.Metadata.UpdatedAt)
Expect(err).Should(BeNil())
Expand All @@ -107,13 +105,13 @@ var _ = Describe("Creating and updating entity via API", Label("e2e", "Entities"
Expect(issue.Type.String()).To(Equal(testUpdatedIssueType))

Expect(issue.Metadata).To(Not(BeNil()))
Expect(*issue.Metadata.CreatedBy).To(Equal(e2e_common.SystemUserId))
Expect(*issue.Metadata.CreatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.SystemUserId)))

createdAt, err := time.Parse(dbDateLayout, *issue.Metadata.CreatedAt)
Expect(err).Should(BeNil())
Expect(createdAt).Should(BeTemporally("~", time.Now().UTC(), 3*time.Second))

Expect(*issue.Metadata.UpdatedBy).To(Equal(e2e_common.SystemUserId))
Expect(*issue.Metadata.UpdatedBy).To(Equal(fmt.Sprintf("%d", e2e_common.SystemUserId)))

updatedAt, err := time.Parse(dbDateLayout, *issue.Metadata.UpdatedAt)
Expect(err).Should(BeNil())
Expand Down

0 comments on commit 353848a

Please sign in to comment.