Skip to content

Commit

Permalink
fix(api): storage dir not being set properly (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion authored Oct 6, 2023
1 parent ab41a72 commit fa31dd4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/api/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export default class Storage {
return;
}

Storage.dir = fs.mkdirSync(path.join(process.cwd(), '.api'), { recursive: true }) as string;
Storage.dir = path.join(process.cwd(), '.api');

fs.mkdirSync(Storage.dir, { recursive: true });
fs.mkdirSync(Storage.getAPIsDir(), { recursive: true });
}

Expand Down
14 changes: 14 additions & 0 deletions packages/api/test/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ describe('storage', () => {
fetchMock.restore();
});

describe('#setStorageDir', () => {
it('should create and set a storage dir if one is neither supplied or already exists', async () => {
Storage.dir = '';

Storage.setStorageDir();

expect(Storage.dir).toContain('/.api');
expect(Storage.getAPIsDir()).toContain('/.api/api');

await expect(fs.stat(Storage.dir)).resolves.toHaveProperty('uid');
await expect(fs.stat(Storage.getAPIsDir())).resolves.toHaveProperty('uid');
});
});

describe('#generateIntegrityHash', () => {
it('should generate an integrity hash for an API definition', () => {
expect(Storage.generateIntegrityHash(petstoreSimple as OASDocument)).toBe(
Expand Down

0 comments on commit fa31dd4

Please sign in to comment.