From c4ba7e4951a3a9c7a856d23b1c8026aea700d142 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Thu, 29 Jun 2017 21:49:55 +1000 Subject: [PATCH] delete test record, and test 'put' function --- crmEntity_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crmEntity_test.go b/crmEntity_test.go index fe202fe..2aa96a5 100644 --- a/crmEntity_test.go +++ b/crmEntity_test.go @@ -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") +}