|
|
|
@@ -1,21 +1,28 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import "testing" |
|
|
|
|
|
|
|
import "encoding/json" |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"os" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
|
func TestCRMAttachFile(t *testing.T) { |
|
|
|
|
|
|
|
path1 := "media_for_test/200x200.png" |
|
|
|
path2 := "/tmp/wechat_hitxy_测试_" + time.Now().Format("2006-Jan-02-05-04-05") |
|
|
|
r, e := crmCreateAttachment("media_for_test/200x200.png") |
|
|
|
|
|
|
|
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_测试") |
|
|
|
crmDownloadAttachmentAs(r.ID, path2) |
|
|
|
|
|
|
|
AssertEqual(t, md5CompFile(path1, path2), true, "attachment should be downloade as same file ") |
|
|
|
|
|
|
|
//TODO: two file should be equal |
|
|
|
delete, e := crmDeleteEntity("Attachment", r.ID) |
|
|
|
AssertEqual(t, delete, true, "temp attachment should have been deleted") |
|
|
|
|
|
|
|
os.Remove(path2) |
|
|
|
} |
|
|
|
|
|
|
|
func TestDecodeJsonResponse(t *testing.T) { |