|
@@ -0,0 +1,43 @@
|
|
|
+'use strict';
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @author Mai
|
|
|
+ * @date
|
|
|
+ * @version
|
|
|
+ */
|
|
|
+
|
|
|
+const { app, assert } = require('egg-mock/bootstrap');
|
|
|
+const path = require('path');
|
|
|
+let savePath;
|
|
|
+const mockData = {};
|
|
|
+
|
|
|
+describe('test/app/service/report_memory.test.js', () => {
|
|
|
+ // 准备测试数据
|
|
|
+ before(function* () {
|
|
|
+ const ctx = app.mockContext();
|
|
|
+ savePath = path.join(ctx.app.baseDir,'report_temp');
|
|
|
+ const postData = {
|
|
|
+ account: 'zengpeiwen',
|
|
|
+ project: 'P1201',
|
|
|
+ project_password: '123456',
|
|
|
+ };
|
|
|
+ ctx.session = {};
|
|
|
+ const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
|
|
|
+ assert(loginResult);
|
|
|
+ mockData.session = ctx.session;
|
|
|
+ });
|
|
|
+ it('test mem_change_bills && mem_change ', function* () {
|
|
|
+ const ctx = app.mockContext(mockData);
|
|
|
+
|
|
|
+ const change = yield ctx.service.reportMemory.getChangeData(2046);
|
|
|
+ if (change instanceof Array) {
|
|
|
+ yield ctx.helper.saveBufferFile(JSON.stringify(change, '', '\t'), path.join(savePath, 'mem_change.json'));
|
|
|
+ }
|
|
|
+ const data = yield ctx.service.reportMemory.getChangeBillsData(2046);
|
|
|
+ if (data instanceof Array) {
|
|
|
+ yield ctx.helper.saveBufferFile(JSON.stringify(data, '', '\t'), path.join(savePath, 'mem_change_bills.json'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|