Skip to content

tests(refactor): Extract mail account management tests from tests.bats#3055

Merged
polarathene merged 8 commits intodocker-mailserver:masterfrom
polarathene:tests/migrate-accounts
Feb 3, 2023
Merged

tests(refactor): Extract mail account management tests from tests.bats#3055
polarathene merged 8 commits intodocker-mailserver:masterfrom
polarathene:tests/migrate-accounts

Conversation

@polarathene
Copy link
Copy Markdown
Member

Description

Test cases should remain mostly the same, except:

  • In the user4 test, there was an account removal at the end that was probably a typo and intended as user4 as a clean-up step (original PR). I've dropped it as it doesn't seem necessary.
  • The account password update check was part of a PR introducing the feature, but the sleep 2 lines don't seem necessary so I've removed those.
  • Two tests without postfix-accounts.cf via an alternative volume and docker run were refactored to not need that a all.
  • tests.bats had two groups of "accounts" tests, I've separated them with some comment headers. The very first test didn't seem as thorough, and improving on that seems to have raised a bug? (_not entirely sure, just that it's related to the Dovecot dummy alias workaround, potentially related feature request [FR] Add the ability to redirect a domain catch-all to some user mailbox #3022 _)

To assist with review, if helpful I've staged changes out into multiple commits improved diffs:

  • First commit handles cut / paste between files.
  • Next commit revises test case descriptions.
  • Followed by refactoring of test cases.

Some test cases could probably be collapsed or changed further, but this is good enough as an initial pass 👍

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

Standard test file format, the test cases have been copied over unmodified.
Revised test cases:
- Some common test case logic extracted to test methods.
- Update direct user management commands to use the `setup email ...` variants.
- Improved assertions.
- Removed `sleep 2` lines as the need for that is ambiguous (may no longer be relevant?)
- Additional commentary for maintaining
- Two test cases for missing `postfix-accounts.cf` opted to just run the image without any volumes instead, as the `without-accounts/` folder  was empty anyway. 2nd test case can instead use a single `docker run` to check  the newly created`postfix-accounts.cf` content.
- `test/config/without-accounts/` remains as `open_dkim.bats` presently uses it.
Traced this back to the original PR where it appears to have been a typo and was probably intended as a cleanup on the `user4` account. Not necessary, removing.
@polarathene polarathene added area/tests kind/improvement Improve an existing feature, configuration file or the documentation labels Feb 3, 2023
@polarathene polarathene added this to the v12.0.0 milestone Feb 3, 2023
@polarathene polarathene self-assigned this Feb 3, 2023
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should take care of the parsing of ls and the directory checks; the rest looks very good!

Comment thread test/tests/parallel/set3/mta/account_management.bats Outdated
Comment thread test/tests/parallel/set3/mta/account_management.bats Outdated
Comment thread test/tests/parallel/set3/mta/account_management.bats Outdated
Comment thread test/tests/parallel/set3/mta/account_management.bats Outdated
Comment thread test/tests/parallel/set3/mta/account_management.bats Outdated
Comment thread test/tests/parallel/set3/mta/account_management.bats Outdated
polarathene and others added 2 commits February 4, 2023 00:11
Replace `ls -d` approach from original test cases

Co-authored-by: Georg Lauterbach <[email protected]>
@polarathene polarathene enabled auto-merge (squash) February 3, 2023 22:52
@polarathene polarathene merged commit 05db27f into docker-mailserver:master Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tests kind/improvement Improve an existing feature, configuration file or the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants