This PR requires PR #89 to be merged as that solves the feature.
The test data are written directly on the code. However, we need to decide how the test data will be managed and where should be stored. Looking for guidelines @Vad1mo @amands98.
These tests do not mock as the motive of e2e is to test if the whole procedure is working fine. Only external modules can be mocked if necessary. Mocking the internal modules would not let to check the integration of all the modules.
Hey @muaz-32 I've already been working in this PR for login testing
Your test cases are part of unit testing, where you tested the runLogin() method. And your TestLoginCommand() is also not a part of e2e testing. So no worries, this is not a conflict of contribution.
Fixes: #23
This PR requires PR #89 to be merged as that solves the feature.
The test data are written directly on the code. However, we need to decide how the test data will be managed and where should be stored. Looking for guidelines @Vad1mo @amands98.
These tests do not mock as the motive of e2e is to test if the whole procedure is working fine. Only external modules can be mocked if necessary. Mocking the internal modules would not let to check the integration of all the modules.
I had to change the
Run
function toRunE
function, because otherwise the assertions could not be tested. The problem is with thefmt.Println()
function, as it will not write to the buffer provided in the test function. I have checked many places and investigated. Their method works because those functions do not usePrintln()
to show the failure. https://nayaktapan37.medium.com/testing-cobra-commands-in-golang-ca1fe4ad6657 https://github.com/spf13/cobra/issues/1790 https://github.com/govcms-tests/govcms-cli/blob/3216b7334c184e2cd52f013f588d2af9529b4929/docs/testing_cobra.mdhttps://github.com/spf13/cobra-cli/tree/main/cmd