webhook_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package webhooks
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "testing"
  5. )
  6. func Test_Webhook_MoveIntoStage(t *testing.T) {
  7. requestString := "leads[status][0][id]=2050297&" +
  8. "leads[status][0][status_id]=35573056&" +
  9. "leads[status][0][pipeline_id]=3643927&" +
  10. "leads[status][0][old_status_id]=35572897&" +
  11. "leads[status][0][old_pipeline_id]=3643927&" +
  12. "account[id]=29085955&" +
  13. "account[subdomain]=domain"
  14. expected := &WebhookRequest{
  15. Leads: Leads{
  16. Status: []Status{
  17. {
  18. Id: "2050297",
  19. StatusId: "35573056",
  20. PipelineId: "3643927",
  21. OldStatusId: "35572897",
  22. OldPipelineId: "3643927",
  23. },
  24. },
  25. },
  26. Account: Account{
  27. Id: "29085955",
  28. SubDomain: "domain",
  29. },
  30. }
  31. webhook, err := NewFromString(requestString)
  32. if err != nil {
  33. t.Fail()
  34. }
  35. if assert.NotNil(t, webhook) {
  36. assert.Equal(t, webhook, expected)
  37. }
  38. }
  39. func Test_Webhook_CreateIntoStage(t *testing.T) {
  40. requestString := "leads[add][0][id]=2232929&" +
  41. "leads[add][0][status_id]=35573056&" +
  42. "leads[add][0][pipeline_id]=3643927&" +
  43. "account[id]=29085955&account[subdomain]=domain"
  44. expected := &WebhookRequest{
  45. Leads: Leads{
  46. Add: []Status{
  47. {
  48. Id: "2232929",
  49. StatusId: "35573056",
  50. PipelineId: "3643927",
  51. },
  52. },
  53. },
  54. Account: Account{
  55. Id: "29085955",
  56. SubDomain: "domain",
  57. },
  58. }
  59. webhook, err := NewFromString(requestString)
  60. if err != nil {
  61. t.Fail()
  62. }
  63. if assert.NotNil(t, webhook) {
  64. assert.Equal(t, webhook, expected)
  65. }
  66. }