Skip to content

Commit

Permalink
feat(service): add mutations for relations
Browse files Browse the repository at this point in the history
  • Loading branch information
MR2011 committed Jul 11, 2024
1 parent 955b67a commit 17ea8c4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/app/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ var _ = Describe("When deleting Activity", Label("app", "DeleteActivity"), func(
})
})

var _ = Describe("When modifying Service and Activity", Label("app", "ServiceActivity"), func() {
var _ = Describe("When modifying relationship of Service and Activity", Label("app", "ServiceActivityRelationship"), func() {
var (
db *mocks.MockDatabase
heureka app.Heureka
Expand Down
3 changes: 3 additions & 0 deletions internal/app/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Heureka interface {
DeleteIssueMatchChange(int64) error

ListServices(*entity.ServiceFilter, *entity.ListOptions) (*entity.List[entity.ServiceResult], error)
GetService(int64) (*entity.Service, error)
CreateService(*entity.Service) (*entity.Service, error)
UpdateService(*entity.Service) (*entity.Service, error)
DeleteService(int64) error
Expand All @@ -48,6 +49,7 @@ type Heureka interface {
DeleteUser(int64) error

ListSupportGroups(*entity.SupportGroupFilter, *entity.ListOptions) (*entity.List[entity.SupportGroupResult], error)
GetSupportGroup(int64) (*entity.SupportGroup, error)
CreateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error)
UpdateSupportGroup(*entity.SupportGroup) (*entity.SupportGroup, error)
DeleteSupportGroup(int64) error
Expand All @@ -60,6 +62,7 @@ type Heureka interface {
DeleteComponentInstance(int64) error

ListActivities(*entity.ActivityFilter, *entity.ListOptions) (*entity.List[entity.ActivityResult], error)
GetActivity(int64) (*entity.Activity, error)
CreateActivity(*entity.Activity) (*entity.Activity, error)
UpdateActivity(*entity.Activity) (*entity.Activity, error)
DeleteActivity(int64) error
Expand Down
2 changes: 1 addition & 1 deletion internal/app/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ var _ = Describe("When modifying owner and Service", Label("app", "OwnerService"
})
})

var _ = Describe("When modifying issueRepository and Service", Label("app", "IssueRepositoryService"), func() {
var _ = Describe("When modifying relationship of issueRepository and Service", Label("app", "IssueRepositoryServiceRelationship"), func() {
var (
db *mocks.MockDatabase
heureka app.Heureka
Expand Down
2 changes: 1 addition & 1 deletion internal/app/support_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ var _ = Describe("When deleting SupportGroup", Label("app", "DeleteSupportGroup"
})
})

var _ = Describe("When modifying Service and SupportGroup", Label("app", "ServiceSupportGroup"), func() {
var _ = Describe("When modifying relationship of Service and SupportGroup", Label("app", "ServiceSupportGroupRelationship"), func() {
var (
db *mocks.MockDatabase
heureka app.Heureka
Expand Down
3 changes: 3 additions & 0 deletions internal/e2e/activity_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,15 @@ var _ = Describe("Modifying Services of Activity via API", Label("e2e", "Service
req := graphql.NewRequest(str)

activity := seedCollection.ActivityRows[0].AsActivity()
// find all services that are assigned to the activity
serviceIds := lo.FilterMap(seedCollection.ActivityHasServiceRows, func(row mariadb.ActivityHasServiceRow, _ int) (int64, bool) {
if row.ActivityId.Int64 == activity.Id {
return row.ServiceId.Int64, true
}
return 0, false
})

// find a service that is not assigned to the activity
serviceRow, _ := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool {
return !lo.Contains(serviceIds, row.Id.Int64)
})
Expand Down Expand Up @@ -459,6 +461,7 @@ var _ = Describe("Modifying Services of Activity via API", Label("e2e", "Service

activity := seedCollection.ActivityRows[0].AsActivity()

// find a service that is assigned to the activity
serviceRow, _ := lo.Find(seedCollection.ActivityHasServiceRows, func(row mariadb.ActivityHasServiceRow) bool {
return row.ActivityId.Int64 == activity.Id
})
Expand Down
4 changes: 3 additions & 1 deletion internal/e2e/service_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,14 @@ var _ = Describe("Modifying IssueRepository of Service via API", Label("e2e", "S
req := graphql.NewRequest(str)

service := seedCollection.ServiceRows[0].AsService()
// find all issueRepositories that are attached to the service
issueRepositoryIds := lo.FilterMap(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow, _ int) (int64, bool) {
if row.ServiceId.Int64 == service.Id {
return row.IssueRepositoryId.Int64, true
}
return 0, false
})

// find an issueRepository that is not attached to the service
issueRepositoryRow, _ := lo.Find(seedCollection.IssueRepositoryRows, func(row mariadb.BaseIssueRepositoryRow) bool {
return !lo.Contains(issueRepositoryIds, row.Id.Int64)
})
Expand Down Expand Up @@ -620,6 +621,7 @@ var _ = Describe("Modifying IssueRepository of Service via API", Label("e2e", "S

service := seedCollection.ServiceRows[0].AsService()

// find an issueRepository that is attached to the service
issueRepositoryRow, _ := lo.Find(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow) bool {
return row.ServiceId.Int64 == service.Id
})
Expand Down
3 changes: 3 additions & 0 deletions internal/e2e/support_group_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,15 @@ var _ = Describe("Modifying Services of SupportGroup via API", Label("e2e", "Sup
req := graphql.NewRequest(str)

supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup()
// find all services that are attached to the supportGroup
serviceIds := lo.FilterMap(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow, _ int) (int64, bool) {
if row.SupportGroupId.Int64 == supportGroup.Id {
return row.ServiceId.Int64, true
}
return 0, false
})

// find a service that is not attached to the supportGroup
serviceRow, _ := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool {
return !lo.Contains(serviceIds, row.Id.Int64)
})
Expand Down Expand Up @@ -491,6 +493,7 @@ var _ = Describe("Modifying Services of SupportGroup via API", Label("e2e", "Sup

supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup()

// find a service that is attached to the supportGroup
serviceRow, _ := lo.Find(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow) bool {
return row.SupportGroupId.Int64 == supportGroup.Id
})
Expand Down

0 comments on commit 17ea8c4

Please sign in to comment.