1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package webhooks
- import (
- "github.com/stretchr/testify/assert"
- "testing"
- )
- func Test_Webhook_MoveIntoStage(t *testing.T) {
- requestString := "leads[status][0][id]=2050297&" +
- "leads[status][0][status_id]=35573056&" +
- "leads[status][0][pipeline_id]=3643927&" +
- "leads[status][0][old_status_id]=35572897&" +
- "leads[status][0][old_pipeline_id]=3643927&" +
- "account[id]=29085955&" +
- "account[subdomain]=domain"
- expected := &WebhookRequest{
- Leads: Leads{
- Status: []Status{
- {
- Id: "2050297",
- StatusId: "35573056",
- PipelineId: "3643927",
- OldStatusId: "35572897",
- OldPipelineId: "3643927",
- },
- },
- },
- Account: Account{
- Id: "29085955",
- SubDomain: "domain",
- },
- }
- webhook, err := NewFromString(requestString)
- if err != nil {
- t.Fail()
- }
- if assert.NotNil(t, webhook) {
- assert.Equal(t, webhook, expected)
- }
- }
- func Test_Webhook_CreateIntoStage(t *testing.T) {
- requestString := "leads[add][0][id]=2232929&" +
- "leads[add][0][status_id]=35573056&" +
- "leads[add][0][pipeline_id]=3643927&" +
- "account[id]=29085955&account[subdomain]=domain"
- expected := &WebhookRequest{
- Leads: Leads{
- Add: []Status{
- {
- Id: "2232929",
- StatusId: "35573056",
- PipelineId: "3643927",
- },
- },
- },
- Account: Account{
- Id: "29085955",
- SubDomain: "domain",
- },
- }
- webhook, err := NewFromString(requestString)
- if err != nil {
- t.Fail()
- }
- if assert.NotNil(t, webhook) {
- assert.Equal(t, webhook, expected)
- }
- }
|