Skip to content

Commit

Permalink
test: add test to service data handler
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed May 15, 2024
1 parent 13bd1b5 commit 13b6646
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/api/v1beta1/servicedata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,31 @@ func TestHandler_CreateKey(t *testing.T) {
want: nil,
wantErr: grpcBadBodyError,
},
{
name: "should return created key if no error",
setup: func(ctx context.Context, ss *mocks.ServiceDataService) context.Context {
ss.EXPECT().CreateKey(mock.AnythingOfType("*context.valueCtx"), servicedata.Key{
ProjectID: testKey.ProjectID,
Key: testKey.Key,
Description: testKey.Description,
}).Return(servicedata.Key{
ID: testKey.ID,
URN: testKey.URN,
}, nil)
return user.SetContextWithEmail(ctx, email)
},
request: &shieldv1beta1.CreateServiceDataKeyRequest{
Body: &shieldv1beta1.ServiceDataKeyRequestBody{
Project: testKey.ProjectID,
Key: testKey.Key,
Description: testKey.Description,
},
},
want: &shieldv1beta1.CreateServiceDataKeyResponse{
ServiceDataKey: testKeyPB,
},
wantErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 13b6646

Please sign in to comment.