feat: add tests for webhook resolvers
This commit is contained in:
@@ -43,5 +43,7 @@ func DeleteWebhookResolver(ctx context.Context, params model.WebhookRequest) (*m
|
||||
return nil, err
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("not implemented"))
|
||||
return &model.Response{
|
||||
Message: "Webhook deleted successfully",
|
||||
}, nil
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ func TestEndpointResolver(ctx context.Context, params model.TestEndpointRequest)
|
||||
}
|
||||
|
||||
if params.EventName == constants.UserLoginWebhookEvent {
|
||||
reqBody["login_method"] = constants.AuthRecipeMethodMagicLinkLogin
|
||||
reqBody["auth_recipe"] = constants.AuthRecipeMethodMagicLinkLogin
|
||||
}
|
||||
|
||||
requestBody, err := json.Marshal(reqBody)
|
||||
|
@@ -52,7 +52,7 @@ func UpdateWebhookResolver(ctx context.Context, params model.UpdateWebhookReques
|
||||
CreatedAt: *webhook.CreatedAt,
|
||||
}
|
||||
|
||||
if webhookDetails.EventName != utils.StringValue(params.EventName) {
|
||||
if params.EventName != nil && webhookDetails.EventName != utils.StringValue(params.EventName) {
|
||||
if isValid := validators.IsValidWebhookEventName(utils.StringValue(params.EventName)); !isValid {
|
||||
log.Debug("invalid event name: ", utils.StringValue(params.EventName))
|
||||
return nil, fmt.Errorf("invalid event name %s", utils.StringValue(params.EventName))
|
||||
@@ -60,11 +60,11 @@ func UpdateWebhookResolver(ctx context.Context, params model.UpdateWebhookReques
|
||||
webhookDetails.EventName = utils.StringValue(params.EventName)
|
||||
}
|
||||
|
||||
if webhookDetails.EndPoint != utils.StringValue(params.Endpoint) {
|
||||
if params.Endpoint != nil && webhookDetails.EndPoint != utils.StringValue(params.Endpoint) {
|
||||
webhookDetails.EventName = utils.StringValue(params.EventName)
|
||||
}
|
||||
|
||||
if webhookDetails.Enabled != utils.BoolValue(params.Enabled) {
|
||||
if params.Enabled != nil && webhookDetails.Enabled != utils.BoolValue(params.Enabled) {
|
||||
webhookDetails.Enabled = utils.BoolValue(params.Enabled)
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,9 @@ func WebhookLogsResolver(ctx context.Context, params model.ListWebhookLogRequest
|
||||
return nil, fmt.Errorf("unauthorized")
|
||||
}
|
||||
|
||||
pagination := utils.GetPagination(params.Pagination)
|
||||
pagination := utils.GetPagination(&model.PaginatedInput{
|
||||
Pagination: params.Pagination,
|
||||
})
|
||||
|
||||
webhookLogs, err := db.Provider.ListWebhookLogs(ctx, pagination, utils.StringValue(params.WebhookID))
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user