archethic-foundation / aeweb-cli

AEWeb CLI to deploy files on Archethic
GNU Affero General Public License v3.0
5 stars 11 forks source link

added-unit-tests #51

Closed manujuniris closed 2 years ago

manujuniris commented 2 years ago

Description

This PR is created to add unit tests to the project.

The following output was captured -

Screenshot from 2022-03-30 11-55-14

ghost commented 2 years ago

Your unit test implementation is not in the right direction. You have rewritten functions in your unit tests, but they should call your existing functions and assert a behavior. So your code implementation should match with the expectations provided in the tests.

Also regarding networking calls, you should use mocks to simulate the response from a server, otherwise in a automatic testing (CI) this will not work.

manujuniris commented 2 years ago

Your unit test implementation is not in the right direction. You have rewritten functions in your unit tests, but they should call your existing functions and assert a behavior. So your code implementation should match with the expectations provided in the tests.

Also regarding networking calls, you should use mocks to simulate the response from a server, otherwise in a automatic testing (CI) this will not work.

ok got it

manujuniris commented 2 years ago

I don't see any assertions here? Is this purposely written?

Something like expecting a console.log message with success text after deployments. or some other way that guarantees the function worked well...

I found a lib to use test console for expecting console messages and so...

I'm getting timeout error, also const output = await new Promise((resolve) => { parser.parse("deploy-file --seed=myseed --endpoint=http://localhost:4000 --file=./aeweb.js", (err, argv, output) => { resolve(output); })

});

output is null here in this case, when I try console.log(output) , the result is null

ghost commented 2 years ago

I suggest to leverage nock to mock the http calls to the archethic node. So you could test with scenario without a ceremony to setup infrastructure for testing.