fix(erpsetup): name the Frappe webhooks #38
No files matched your search
@@ -182,3 +182,14 @@ func TestWebhookBodiesAreValidJSONShapes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebhookDocIsNamed(t *testing.T) {
|
||||
seen := map[string]bool{}
|
||||
for _, w := range webhooks("https://r.test/hook", "s") {
|
||||
name, _ := w.doc()["name"].(string)
|
||||
if name != "breakpilot-"+w.Event || seen[name] {
|
||||
t.Fatalf("webhook %s: name %q", w.Event, name)
|
||||
}
|
||||
seen[name] = true
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,10 @@ type webhook struct {
|
||||
|
||||
func (w webhook) doc() map[string]any {
|
||||
return map[string]any{
|
||||
"doctype": "Webhook",
|
||||
"doctype": "Webhook",
|
||||
// Frappe names a Webhook by prompt: without a name the insert fails
|
||||
// with "Please enter the document name".
|
||||
"name": "breakpilot-" + w.Event,
|
||||
"webhook_doctype": w.Doctype,
|
||||
"webhook_docevent": w.DocEvent,
|
||||
"condition": w.Condition,
|
||||
|
||||
Reference in new issue
Block a user