| @@ -63,6 +63,10 @@ func TestCreateDuplicate(t *testing.T) { | |||
| entity, err := crmCreateEntity("Lead", b) | |||
| AssertEqual(t, err == nil, false, "should have error for duplicates") | |||
| AssertEqual(t, isErrIndicateDuplicate(err), true, "the err should be duplicate error") | |||
| //delete | |||
| deleted, _ := crmDeleteEntity("Lead", entity.(crmdLead).ID) | |||
| AssertEqual(t, deleted, true, "test record should be deleted") | |||
| } | |||
| func TestCrmCreateEntityServerNotFound(t *testing.T) { | |||
| @@ -81,3 +85,27 @@ func TestCrmCreateEntityServerNotFound(t *testing.T) { | |||
| AssertEqual(t, entity, nil, "should not be able to create entity, it should be nil") | |||
| } | |||
| func TestCrmReplaceEntity(t *testing.T) { | |||
| SetupConfig() | |||
| e := crmdLead{} | |||
| e.FirstName = "ff" + time.Now().Format("2006-jan-02 03:04:05") | |||
| e.LastName = "ll" | |||
| e.Password = "pp" | |||
| e.Status = "New" | |||
| e.WechatHitxyID = "someopenid" | |||
| b, _ := json.Marshal(e) | |||
| entity, err := crmCreateEntity("Lead", b) | |||
| AssertEqual(t, isErrIndicateDuplicate(err), false, "this should not be a duplicate error") | |||
| id := entity.(crmdLead).ID | |||
| //put | |||
| e.WechatHitxyID = "newid" | |||
| e.Password = "newpass" | |||
| nb, _ := json.Marshal(e) | |||
| entity, err = crmReplaceEntity("Lead", id, nb) | |||
| AssertEqual(t, err, nil, "put should have no error") | |||
| AssertEqual(t, entity.(crmdLead).WechatHitxyID, "newid", "wechat_hitxy_id should be updated") | |||
| AssertEqual(t, entity.(crmdLead).Password, "newpass", "password should have been changed to newpass") | |||
| } | |||