Commit 35c8728
authored
feat: import Slack bot users as Mattermost bot accounts (#79)
* feat: e2e testing boilerplate
* fix: allow custom image and version on e2e tests
* refactor: move slack fixtures to testhelper package
Prevents test utilities from being compiled and published with the
services/slack package while keeping them importable by any test.
* fix: address resource leaks, missing validation, and data correctness issues
- Terminate orphaned containers on error in Postgres and Mattermost setup
- Validate Docker Hub HTTP status before decoding response
- Add json:"-" tag to SlackChannel.Type to clarify it is computed
- Only set DeleteAt on user export when user is actually deleted
* fix: resolve gofmt and staticcheck lint errors
* rename: BasicExport -> SlackBasicExport
* e2e: added e2e tests
* chore: support GO_TEST_FLAGS in `make test`
* fix: reset cobra flags between e2e subtests to prevent state leakage
Reset all flag values and Changed state on the shared RootCmd before
each Execute() call, preventing flag pollution across subtests. Also
fix duplicate step numbering in test comments.
* feat: import Slack bot users as Mattermost bot accounts
Slack bot users are now exported as native Mattermost bot records
(type "bot" with BotImportData) instead of regular user accounts.
This ensures bots get proper Bot records with IsBot=true, avoids
email validation issues for bots, and correctly attributes bot posts.
Adds --bot-owner CLI flag (required when bots are present) to set
the owner of all imported bots. Bots are skipped during Sanitise
and PopulateUserMemberships. Placeholder bots created for missing
bot references in posts are also exported as bot type.
Includes unit tests for all new functions and e2e tests verifying
bot import, bot posts, --bot-owner validation, and deleted bots.
* fix: resolve variable shadowing lint error in bot e2e test
* docs: regenerate CLI docs to include --bot-owner flag
* fix: improve test helper robustness for cross-platform and cancellation
- Set ImagePlatform to linux/amd64 for the Mattermost container so
Docker pulls the correct image on ARM hosts (no arm64 variant exists)
- Normalize ZIP entry paths with filepath.ToSlash for cross-platform
compliance
- Respect context cancellation in the import job polling loop
* ci: disable coderabbit automatic reviews
* fix: detect bot messages by BotId field and harden bot import validation
- Change IsBotMessage() to check BotId != "" instead of relying on
subtype, ensuring posts from bots are correctly routed regardless of
their subtype field
- Move bot message case before plain message in TransformPosts switch
to prevent bot posts from being misattributed to regular users
- Guard against empty BotID in TransformUsers, falling back to user ID
- Trim whitespace on --bot-owner flag to reject whitespace-only values
- Add defensive validation in ExportUsers to fail fast if bots exist
but botOwner is empty
- Add regression test for empty BotID fallback behavior
- Use transformLogFile constant in e2e test cleanup
- Fix GetBotByUsername docstring to reflect actual error propagation
- Remove Description from bot export (no longer set)
* test: add e2e test for non-existent bot owner username
Mattermost's importBot silently accepts unknown owner usernames by
falling back to plugin-owner semantics (storing the raw string as
OwnerId). This test documents that behaviour so we notice if
server-side semantics change.
* ci: trigger CI run
* fix: log username instead of email for imported Slack users
Bot users may not have email addresses, making the previous log
message unhelpful. Username is always available and more useful
for identifying imported users.
* fix: handle bot messages with empty BotId by falling back to User/BotUsername fields
Some Slack exports contain messages with subtype "bot_message" but no
BotId. Expand IsBotMessage() to also match on SubType and add a fallback
chain (User → BotUsername → timestamp placeholder) so these messages are
no longer silently dropped during import.
* fix: correct misspelling of 'existent' in e2e test1 parent 614cb5f commit 35c8728
File tree
13 files changed
+1175
-63
lines changed- commands
- docs/cli
- services/slack
- testhelper
13 files changed
+1175
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
143 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
144 | 159 | | |
145 | 160 | | |
146 | 161 | | |
| |||
0 commit comments