diff --git a/crmAttachment_test.go b/crmAttachment_test.go index 5655db3..f18147a 100644 --- a/crmAttachment_test.go +++ b/crmAttachment_test.go @@ -1,14 +1,21 @@ package main import "testing" -import "log" + import "encoding/json" func TestCRMAttachFile(t *testing.T) { - + 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) { @@ -21,10 +28,3 @@ func TestDecodeJsonResponse(t *testing.T) { err := json.Unmarshal([]byte(msg), &info) AssertEqual(t, err, nil, "json decode shold be correct") } - -func TestCRMDownloadAttachment(t *testing.T) { - - id := "59054884ef1b0c04f" - //crmDownloadAttachment(id) - crmDownloadAttachmentAs(id, "/tmp/wechat_hitxy_测试") -}