feat: add tests for webhook resolvers

This commit is contained in:
Lakhan Samani
2022-07-11 19:40:54 +05:30
parent 334041d0e4
commit 018a13ab3c
24 changed files with 381 additions and 31 deletions

View File

@@ -23,7 +23,7 @@ func NewBoolRef(v bool) *bool {
// BoolValue returns the value of the given bool ref
func BoolValue(r *bool) bool {
if r != nil {
if r == nil {
return false
}
return *r

View File

@@ -20,7 +20,11 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
return err
}
userBytes, err := json.Marshal(user)
if !BoolValue(webhook.Enabled) {
return nil
}
userBytes, err := json.Marshal(user.AsAPIUser())
if err != nil {
log.Debug("error marshalling user obj: ", err)
return err
@@ -78,7 +82,7 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
statusCode := int64(resp.StatusCode)
_, err = db.Provider.AddWebhookLog(ctx, models.WebhookLog{
HttpStatus: statusCode,
Request: string(requestBytesBuffer.Bytes()),
Request: string(requestBody),
Response: string(responseBytes),
WebhookID: webhook.ID,
})