| package main | package main | ||||
| import "testing" | import "testing" | ||||
| import "log" | |||||
| import "encoding/json" | import "encoding/json" | ||||
| func TestCRMAttachFile(t *testing.T) { | func TestCRMAttachFile(t *testing.T) { | ||||
| r, e := crmCreateAttachment("media_for_test/200x200.png") | r, e := crmCreateAttachment("media_for_test/200x200.png") | ||||
| log.Println(r) | |||||
| log.Println(e) | |||||
| AssertEqual(t, e, nil, "should be no error when create attachment") | |||||
| AssertEqual(t, r.ID != "", true, "ID should not be empty ") | |||||
| // | |||||
| crmDownloadAttachmentAs(r.ID, "/tmp/wechat_hitxy_测试") | |||||
| //TODO: two file should be equal | |||||
| delete, e := crmDeleteEntity("Attachment", r.ID) | |||||
| AssertEqual(t, delete, true, "temp attachment should have been deleted") | |||||
| } | } | ||||
| func TestDecodeJsonResponse(t *testing.T) { | func TestDecodeJsonResponse(t *testing.T) { | ||||
| err := json.Unmarshal([]byte(msg), &info) | err := json.Unmarshal([]byte(msg), &info) | ||||
| AssertEqual(t, err, nil, "json decode shold be correct") | AssertEqual(t, err, nil, "json decode shold be correct") | ||||
| } | } | ||||
| func TestCRMDownloadAttachment(t *testing.T) { | |||||
| id := "59054884ef1b0c04f" | |||||
| //crmDownloadAttachment(id) | |||||
| crmDownloadAttachmentAs(id, "/tmp/wechat_hitxy_测试") | |||||
| } |