[MM-63556] mmctl: Add compliance export download cmd (#30576)

* add mmctl compliance export download command and tests

- Introduced `ComplianceExportDownloadCmd` to facilitate downloading compliance export files.
- Implemented the `DownloadComplianceExport` method in the Client interface for handling file downloads.
- Added unit tests for the download command, covering successful downloads, error handling for non-existent jobs, and retries on failure.
- Included end-to-end tests to validate the command's functionality.
- Updated documentation to include usage examples and options for the new command.

* don't know why this was left out

* PR comments

* adjust test for new retry logic

* refactored download fn for compliance_export and export

* fix test due to fixed logic

* docs
Этот коммит содержится в:
Christopher Poile
2025-06-24 16:27:54 -04:00
коммит произвёл GitHub
родитель 60a747f975
Коммит b33a7e362f
12 изменённых файлов: 548 добавлений и 22 удалений

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/mattermost/mattermost/server/v8"
@@ -193,7 +194,7 @@ func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
cmd.Flags().Int("num-retries", 5, "")
err := exportDownloadCmdF(s.th.Client, cmd, []string{exportName})
s.Require().EqualError(err, "failed to download export after 5 retries")
s.Require().EqualError(err, "failed to download export after 5 retries: You do not have the appropriate permissions.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
@@ -227,7 +228,7 @@ func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
defer os.Remove(downloadPath)
err = exportDownloadCmdF(c, cmd, []string{exportName, downloadPath})
s.Require().EqualError(err, "failed to download export after 5 retries")
s.Require().EqualError(err, "failed to download export after 5 retries: Unable to find export file.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
@@ -252,7 +253,8 @@ func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
err = exportDownloadCmdF(c, cmd, []string{exportName, downloadPath})
s.Require().Nil(err)
s.Require().Empty(printer.GetLines())
s.Require().Len(printer.GetLines(), 1)
s.Require().True(strings.HasPrefix(printer.GetLines()[0].(string), "Export file downloaded to "))
s.Require().Empty(printer.GetErrorLines())
})
@@ -273,7 +275,8 @@ func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
err = exportDownloadCmdF(c, cmd, []string{exportName, downloadPath})
s.Require().Nil(err)
s.Require().Empty(printer.GetLines())
s.Require().Len(printer.GetLines(), 1)
s.Require().True(strings.HasPrefix(printer.GetLines()[0].(string), "Export file downloaded to "))
s.Require().Empty(printer.GetErrorLines())
expected, err := os.ReadFile(exportFilePath)