Skip to content

Commit

Permalink
remove one more usage of fs.promises
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Dec 22, 2019
1 parent 7ea2091 commit 522227b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/core/server/uuid/resolve_uuid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* under the License.
*/

import { promises } from 'fs';
import Fs from 'fs';
import { join } from 'path';
import { resolveInstanceUuid } from './resolve_uuid';
import { configServiceMock } from '../config/config_service.mock';
import { loggingServiceMock } from '../logging/logging_service.mock';
import { BehaviorSubject } from 'rxjs';
import { Logger } from '../logging';

const { readFile, writeFile } = promises;
const { readFile, writeFile } = Fs;

jest.mock('uuid', () => ({
v4: () => 'NEW_UUID',
Expand All @@ -35,11 +35,8 @@ jest.mock('fs', () => {
const actual = jest.requireActual('fs');
return {
...actual,
promises: {
...actual.promises,
readFile: jest.fn(() => Promise.resolve('')),
writeFile: jest.fn(() => Promise.resolve('')),
},
readFile: jest.fn().mockImplementation((...args) => process.nextTick(args.pop())),
writeFile: jest.fn().mockImplementation((...args) => process.nextTick(args.pop())),
};
});

Expand Down
6 changes: 4 additions & 2 deletions src/core/server/uuid/resolve_uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
*/

import uuid from 'uuid';
import { promises } from 'fs';
import Fs from 'fs';
import { promisify } from 'util';
import { join } from 'path';
import { take } from 'rxjs/operators';
import { IConfigService } from '../config';
import { PathConfigType, config as pathConfigDef } from '../path';
import { HttpConfigType, config as httpConfigDef } from '../http';
import { Logger } from '../logging';

const { readFile, writeFile } = promises;
const readFile = promisify(Fs.readFile);
const writeFile = promisify(Fs.writeFile);

const FILE_ENCODING = 'utf8';
const FILE_NAME = 'uuid';
Expand Down

0 comments on commit 522227b

Please sign in to comment.