|
- package main
-
- import "testing"
-
- import "encoding/json"
-
- func TestCRMAttachFile(t *testing.T) {
-
- 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_测试")
-
- //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) {
- msg := `
- {"id":"591e55398345683ee","name":"static_qr_code_without_logo.png","deleted":false,"type":"image\/png"
- ,"size":509,"sourceId":null,"createdAt":"2017-05-19 02:15:21","role":"Attachment","storage":null,"storageFilePath"
- :null,"global":false,"parentId":null,"parentType":null,"relatedId":null,"relatedType":null,"createdById"
- :"1","createdByName":"Admin"} `
- info := attachmentInfo{}
- err := json.Unmarshal([]byte(msg), &info)
- AssertEqual(t, err, nil, "json decode shold be correct")
- }
|