Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end to end tests to the "showCommandCmdF" mmctl command #15943

Open
mgdelacroix opened this issue Oct 13, 2020 · 10 comments
Open

Add end to end tests to the "showCommandCmdF" mmctl command #15943

mgdelacroix opened this issue Oct 13, 2020 · 10 comments

Comments

@mgdelacroix
Copy link
Member

mgdelacroix commented Oct 13, 2020

Mattermost is increasing the end to end test coverage for the mmctl CLI tool. The goal is to create a suite of tests that check the main logic paths of each command and ensure that they work against a running server.

This Help Wanted issue covers the addition of end to end tests to the showCommandCmdF command, in the commands/command.go file. The expected way to add these tests is to create a test function in the commands/command_e2e_test.go file and add one s.Run block for each possible test case.

Thanks to the good amount of already existing unit tests that the commands have, it is not necessary to write an end to end test for every possible logic path of the command; the main focus should be in covering the happy path, the error path and the cases where the user doesn't have permissions to perform an action.

To help with the test process, there are some helpers that can be used. The s.SetupTestHelper().InitBasic() chain will create a set of default users, teams and channels to be used during the tests, s.RunForAllClients is useful when a test case should be valid for a sysadmin user, a local mode user and an unprivileged user, and s.RunForSystemAdminAndLocal will test a block for both a sysadmin user and a local mode user. Please take a look at the example pull request to see how all these work.

Example: mattermost/mmctl#202

For instructions on how to set up the end to end tests, take a look at the corresponding section of the mmctl README.

If you have questions about the ticket or you need any help, feel free to post your question in the community CLI channel or contact miguel.delacruz in https://community.mattermost.com/


If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.

JIRA: https://mattermost.atlassian.net/browse/MM-29565

@djanda97
Copy link
Contributor

I would like to give this issue a shot!

@mgdelacroix
Copy link
Member Author

Sure @djanda97, thanks for taking a look at the issue!!

@djanda97
Copy link
Contributor

I am having some trouble building mmctl. When I cloned a fresh copy and ran make build inside the mmctl directory this is the output I receive in the terminal:
go mod vendor
go mod tidy
Running gofmt
Checking github.com/mattermost/mmctl
Checking github.com/mattermost/mmctl/client
Checking github.com/mattermost/mmctl/commands
Checking github.com/mattermost/mmctl/mocks
Checking github.com/mattermost/mmctl/printer
Gofmt success
Running golangci-lint
golangci-lint run ./...
WARN [runner/nolint] Found unknown linters in //nolint directives: ifelsechain
commands/group_test.go:629:3: commentFormatting: put a space between//and comment text (gocritic)
//grp1 := model.GroupWithSchemeAdmin{}
^
commands/init.go:113:22: G402: TLS MinVersion too low. (gosec)
TLSClientConfig: &tls.Config{
VerifyPeerCertificate: VerifyCertificates,
},
make: *** [Makefile:68: govet] Error 1

Do you have any ideas about what could be causing this error?

@born2ngopi
Copy link

@djanda97 try pulling the latest master

@djanda97
Copy link
Contributor

I was successfully able to build mmctl and run the existing e2e tests, however I can't find the commands/command_e2e_test.go file in the mmctl repo. Is this a typo or should I create the file myself?

@wijayaerick
Copy link

@djanda97 You should create the file

@djanda97
Copy link
Contributor

@djanda97 You should create the file

Great, thanks!

@mgdelacroix
Copy link
Member Author

Hi @djanda97! Are you still planning to work on this issue? Is there anything we can help with?

@djanda97
Copy link
Contributor

djanda97 commented Jan 1, 2021

Hi @mgdelacroix! Yes, I still plan on working on this issue, I've just been busy with my new job.

@djanda97 djanda97 removed their assignment Jan 30, 2021
@rdanielwetan
Copy link

I would like to work on this please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants