TestMod_upload.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "mod_upload.h"
  2. #include "upload.h"
  3. #include "XZipZilb.h"
  4. #include "fileutil.h"
  5. TEST_CASE_ENTITY_CLASS(CUploadEntity, "upload_fresh")
  6. {
  7. LOG_FUNCTION();
  8. struct list_head m_updir_list;//文件夹配置列表
  9. INIT_LIST_HEAD(&m_updir_list);
  10. CSimpleStringA checkStr = "";
  11. ErrorCodeEnum Error = (ErrorCodeEnum)upload_create(&m_updir_list, this->GetFunction().GetRawPointer(), checkStr);
  12. if (Error == Error_Succeed) {
  13. Dbg("upload_create is success");
  14. upload_fresh(&m_updir_list);
  15. }
  16. return Error;
  17. }
  18. #ifdef RVC_OS_WIN
  19. TEST_CASE_ENTITY_CLASS(CUploadEntity, "ZipData")
  20. {
  21. LOG_FUNCTION();
  22. string fileZipName = "c:\\testZip&650000000.zip";
  23. string destFile = "c:\\20201010.log";
  24. if (!ExistsFileA(destFile.c_str())) {
  25. FILE* f = fopen(destFile.c_str(), "wb");
  26. if (f != NULL) {
  27. string wStr = "test zip file";
  28. fwrite(wStr.c_str(), wStr.length(), 1, f);
  29. fclose(f);
  30. }
  31. else {
  32. Dbg("createFile fail");
  33. return Error_Exception;
  34. }
  35. }
  36. if (ZipData(fileZipName.c_str(), destFile.c_str())) {
  37. return Error_Succeed;
  38. }
  39. else {
  40. return Error_Exception;
  41. }
  42. }
  43. #else
  44. TEST_CASE_ENTITY_CLASS(CUploadEntity, "CreateZipFromFile")
  45. {
  46. LOG_FUNCTION();
  47. string fileZipName = "/opt/rvc/testZip&650000000.zip";
  48. string destFile = "/opt/rvc/20201010.log";
  49. if (!ExistsFileA(destFile.c_str())) {
  50. FILE* f = fopen(destFile.c_str(), "wb");
  51. if (f != NULL) {
  52. string wStr = "test zip file";
  53. fwrite(wStr.c_str(), wStr.length(), 1, f);
  54. fclose(f);
  55. }
  56. else {
  57. Dbg("createFile fail");
  58. return Error_Exception;
  59. }
  60. }
  61. if (CreateZipFromFile(destFile, fileZipName)) {
  62. return Error_Succeed;
  63. }
  64. else {
  65. return Error_Exception;
  66. }
  67. }
  68. #endif // RVC_OS_WIN