Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

31 lignes
1.0KB

  1. package main
  2. import "testing"
  3. import "encoding/json"
  4. func TestCRMAttachFile(t *testing.T) {
  5. r, e := crmCreateAttachment("media_for_test/200x200.png")
  6. AssertEqual(t, e, nil, "should be no error when create attachment")
  7. AssertEqual(t, r.ID != "", true, "ID should not be empty ")
  8. //
  9. crmDownloadAttachmentAs(r.ID, "/tmp/wechat_hitxy_测试")
  10. //TODO: two file should be equal
  11. delete, e := crmDeleteEntity("Attachment", r.ID)
  12. AssertEqual(t, delete, true, "temp attachment should have been deleted")
  13. }
  14. func TestDecodeJsonResponse(t *testing.T) {
  15. msg := `
  16. {"id":"591e55398345683ee","name":"static_qr_code_without_logo.png","deleted":false,"type":"image\/png"
  17. ,"size":509,"sourceId":null,"createdAt":"2017-05-19 02:15:21","role":"Attachment","storage":null,"storageFilePath"
  18. :null,"global":false,"parentId":null,"parentType":null,"relatedId":null,"relatedType":null,"createdById"
  19. :"1","createdByName":"Admin"} `
  20. info := attachmentInfo{}
  21. err := json.Unmarshal([]byte(msg), &info)
  22. AssertEqual(t, err, nil, "json decode shold be correct")
  23. }