Skip to content

Commit

Permalink
fix: fetch service data
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed Jun 3, 2024
1 parent 19b25a5 commit 6dd586c
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
57 changes: 57 additions & 0 deletions core/servicedata/mocks/servicedata_repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions internal/api/v1beta1/mocks/servicedata_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/api/v1beta1/servicedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (h Handler) UpsertGroupServiceData(ctx context.Context, request *shieldv1be
for k, v := range requestBody.Data {
serviceDataResp, err := h.serviceDataService.Upsert(ctx, servicedata.ServiceData{
EntityID: groupEntity.ID,
NamespaceID: groupNamepaceID,
NamespaceID: groupNamespaceID,
Key: servicedata.Key{
Key: k,
ProjectID: requestBody.Project,
Expand Down
10 changes: 7 additions & 3 deletions internal/api/v1beta1/servicedata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
}
testGroupServiceDataCreate = servicedata.ServiceData{
EntityID: testEntityID,
NamespaceID: groupNamepaceID,
NamespaceID: groupNamespaceID,
Key: servicedata.Key{
Key: testKeyName,
ProjectID: testKeyProjectID,
Expand Down Expand Up @@ -255,15 +255,15 @@ func TestHandler_UpdateUserServiceData(t *testing.T) {
{
name: "should return bad body error if user id or email in param does not exist",
request: &shieldv1beta1.UpsertUserServiceDataRequest{
UserId: testEntityID,
UserId: "",
Body: &shieldv1beta1.UpsertServiceDataRequestBody{
Data: map[string]string{
testKeyName: testValue,
},
},
},
setup: func(ctx context.Context, ss *mocks.ServiceDataService, us *mocks.UserService) context.Context {
us.EXPECT().Get(mock.AnythingOfType("context.todoCtx"), testEntityID).Return(user.User{}, user.ErrInvalidEmail)
us.EXPECT().Get(mock.AnythingOfType("context.todoCtx"), "").Return(user.User{}, user.ErrInvalidEmail)
return ctx
},
want: nil,
Expand Down Expand Up @@ -338,6 +338,10 @@ func TestHandler_UpdateUserServiceData(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
mockServiceDataService := new(mocks.ServiceDataService)
mockUserService := new(mocks.UserService)
ctx := context.TODO()
if tt.setup != nil {
ctx = tt.setup(ctx, mockServiceDataService, mockUserService)
}
mockDep := Handler{serviceDataService: mockServiceDataService, userService: mockUserService, serviceDataConfig: ServiceDataConfig{MaxUpsert: 1}}
resp, err := mockDep.UpsertUserServiceData(ctx, tt.request)
assert.EqualValues(t, tt.want, resp)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e_test/testbench/testdata/configs/rules/rule.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rules:
- backends:
- name: entropy
target: "http://localhost:56677"
target: "http://localhost:49957"
frontends:
- name: ping
path: "/api/ping"
Expand Down

0 comments on commit 6dd586c

Please sign in to comment.