-
Notifications
You must be signed in to change notification settings - Fork 3
[DD-140] Introduce one more abstraction layer on top of helpers with mocha logic (hooks, timeouts) #85
Conversation
@@ -32,6 +32,8 @@ async function spawnAndPromisifyIpfs() { | |||
|
|||
ipfsd.stop = util.promisify(ipfsd.stop).bind(ipfsd); | |||
ipfsd.cleanup = util.promisify(ipfsd.cleanup).bind(ipfsd); | |||
ipfsd.api.clean = ipfsd.cleanup; | |||
ipfsd.api.remove = ipfsd.stop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should review IPFS helper to follow the same interface as the other ones. Probably we should have an IPFSInstance.
Should we create an issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like the idea to mutate API object. Let's use a plain object for instance temporary?
return {
getApi() {
return ipfsd.api;
},
remove: ipfsd.stop,
clean: ipfsd.cleanup,
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I also prefer this approach. I didn't follow it at first because I don't want to modify the clients since we are returning ipfsd.api.
clean: async function clean() { | ||
await callInParallel(instance, 'clean'); | ||
}, | ||
remove: async function clean() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one needs a review too. We should follow the same interface (clean, remove) for all the startServiceInstance.
Right now this works, so, I'd say create a new issue.
@@ -32,6 +32,8 @@ async function spawnAndPromisifyIpfs() { | |||
|
|||
ipfsd.stop = util.promisify(ipfsd.stop).bind(ipfsd); | |||
ipfsd.cleanup = util.promisify(ipfsd.cleanup).bind(ipfsd); | |||
ipfsd.api.clean = ipfsd.cleanup; | |||
ipfsd.api.remove = ipfsd.stop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like the idea to mutate API object. Let's use a plain object for instance temporary?
return {
getApi() {
return ipfsd.api;
},
remove: ipfsd.stop,
clean: ipfsd.cleanup,
};
* @returns {Promise<DockerInstance>} | ||
*/ | ||
async clean() { | ||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to support chained interface for all class methods or just for this? Do we really need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in reality, we just want a clean method for all DockerInstance. It could be an empty method to avoid breaking startHelperWithMochaHooksFactory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... let's keep it empty for a while.
before(async function before() { | ||
this.timeout(25000); | ||
const ipfsApi = await startIPFSInstance(); | ||
startIPFSInstance().then((ipfsApi) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe('StateTransitionHeader', async () => {
...
const ipfsApi = await startIPFSInstance();
const addSTPacket = addSTPacketFactory(ipfsApi);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, describe does not support async/await.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(( Promise-based syntax here looks ugly. Could we call it in before
? I think we can call before
in before
and it should work without downsides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work either. Keep in mind that our solution has some trade-offs. Dealing with timeouts and hooks outside test suite make the code less explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, ok. Let's keep this as is.
@@ -0,0 +1,7 @@ | |||
/* eslint-disable global-require */ | |||
describe('mocha', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Mocha'
|
||
describe('Three instances', () => { | ||
let instances; | ||
startDashCoreInstance.many(3).then((_instances) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use await
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 👍
https://dashpay.atlassian.net/browse/DD-140