Change configure Jupyter server steps from async to sync (#13937)

* change config steps to sync

* fix tests

* use pathexistsSync

* remove pathExistsSync call

* address PR comments
This commit is contained in:
Lucy Zhang
2021-01-20 15:45:54 -08:00
committed by GitHub
parent 58d4dda1e8
commit 068649cba4
5 changed files with 29 additions and 33 deletions

View File

@@ -55,17 +55,15 @@ describe('Jupyter server instance', function (): void {
it('Should create config and data directories on configure', async function (): Promise<void> {
// Given a server instance
let mkdirStub = sinon.stub(utils,'mkDir').withArgs(sinon.match.any,sinon.match.any).returns(Promise.resolve());
let copyStub = sinon.stub(fs,'copy').returns();
let pathStub = sinon.stub(utils,'exists').withArgs(sinon.match.any).returns(Promise.resolve(false));
let ensureDirSyncStub = sinon.stub(utils,'ensureDirSync').withArgs(sinon.match.any,sinon.match.any).returns();
let copyStub = sinon.stub(fs,'copySync').returns();
// When I run configure
await serverInstance.configure();
// Then I expect a folder to have been created with config and data subdirs
sinon.assert.callCount(mkdirStub,5);
sinon.assert.callCount(ensureDirSyncStub,5);
sinon.assert.callCount(copyStub,3);
sinon.assert.callCount(pathStub,1);
});
it('Should have URI info after start', async function (): Promise<void> {
@@ -152,8 +150,8 @@ describe('Jupyter server instance', function (): void {
it('Should remove directory on close', async function (): Promise<void> {
// Given configure and startup are done
sinon.stub(utils,'mkDir').withArgs(sinon.match.any,sinon.match.any).returns(Promise.resolve());
sinon.stub(fs,'copy').returns();
sinon.stub(utils,'ensureDirSync').withArgs(sinon.match.any,sinon.match.any).returns();
sinon.stub(fs,'copySync').returns();
let process = setupSpawn({
sdtout: (listener: (msg: string) => void) => { },