report_memory_temp.test.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const path = require('path');
  11. let savePath;
  12. const mockData = {};
  13. describe('test/app/service/report_memory.test.js', () => {
  14. // 准备测试数据
  15. before(function* () {
  16. const ctx = app.mockContext();
  17. savePath = path.join(ctx.app.baseDir,'report_temp');
  18. const postData = {
  19. account: 'zengpeiwen',
  20. project: 'P1201',
  21. project_password: '123456',
  22. };
  23. ctx.session = {};
  24. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  25. assert(loginResult);
  26. mockData.session = ctx.session;
  27. });
  28. it('test mem_change_bills && mem_change ', function* () {
  29. const ctx = app.mockContext(mockData);
  30. const change = yield ctx.service.reportMemory.getChangeData(2046);
  31. if (change instanceof Array) {
  32. yield ctx.helper.saveBufferFile(JSON.stringify(change, '', '\t'), path.join(savePath, 'mem_change.json'));
  33. }
  34. const data = yield ctx.service.reportMemory.getChangeBillsData(2046);
  35. if (data instanceof Array) {
  36. yield ctx.helper.saveBufferFile(JSON.stringify(data, '', '\t'), path.join(savePath, 'mem_change_bills.json'));
  37. }
  38. });
  39. });