Преглед на файлове

delete test record, and test 'put' function

master
Patrick Peng Sun преди 8 години
родител
ревизия
c4ba7e4951
променени са 1 файла, в които са добавени 28 реда и са изтрити 0 реда
  1. +28
    -0
      crmEntity_test.go

+ 28
- 0
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")
}

Loading…
Отказ
Запис