Print & Return errors using multierror if an error happens (#26625)
* Print & Return errors using multierror if an error happens * Group up errors assertion in test * Remove trailing newspace * Remove WrappedErrors loop --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -1783,13 +1783,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
|
||||
Times(1)
|
||||
|
||||
err := unarchiveChannelsCmdF(s.client, cmd, args)
|
||||
s.Require().Nil(err)
|
||||
expectedError := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
|
||||
s.Require().ErrorContains(err, expectedError)
|
||||
s.Require().Equal(expectedError, printer.GetErrorLines()[0])
|
||||
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
|
||||
actual := printer.GetErrorLines()[0]
|
||||
expected := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
s.Require().Equal(expected, actual)
|
||||
})
|
||||
|
||||
s.Run("Fail to unarchive a non-existing channel on an existent team", func() {
|
||||
@@ -1821,13 +1821,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
|
||||
Times(1)
|
||||
|
||||
err := unarchiveChannelsCmdF(s.client, cmd, args)
|
||||
s.Require().Nil(err)
|
||||
expectedError := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
|
||||
s.Require().ErrorContains(err, expectedError)
|
||||
s.Require().Equal(expectedError, printer.GetErrorLines()[0])
|
||||
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
|
||||
actual := printer.GetErrorLines()[0]
|
||||
expected := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
s.Require().Equal(expected, actual)
|
||||
})
|
||||
|
||||
s.Run("Fail to unarchive a non-existing channel", func() {
|
||||
@@ -1844,13 +1844,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
|
||||
Times(1)
|
||||
|
||||
err := unarchiveChannelsCmdF(s.client, cmd, args)
|
||||
s.Require().Nil(err)
|
||||
expectedError := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
|
||||
s.Require().ErrorContains(err, expectedError)
|
||||
s.Require().Equal(expectedError, printer.GetErrorLines()[0])
|
||||
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
|
||||
actual := printer.GetErrorLines()[0]
|
||||
expected := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
s.Require().Equal(expected, actual)
|
||||
})
|
||||
|
||||
s.Run("Fail to unarchive an existing channel when client throws error", func() {
|
||||
@@ -1875,13 +1875,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
|
||||
Times(1)
|
||||
|
||||
err := unarchiveChannelsCmdF(s.client, cmd, args)
|
||||
s.Require().Nil(err)
|
||||
expectedError := fmt.Sprintf("Unable to unarchive channel '%s'. Error: %s", channelName, mockErr.Error())
|
||||
|
||||
s.Require().ErrorContains(err, expectedError)
|
||||
s.Require().Equal(expectedError, printer.GetErrorLines()[0])
|
||||
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
|
||||
actual := printer.GetErrorLines()[0]
|
||||
expected := fmt.Sprintf("Unable to unarchive channel '%s'. Error: %s", channelName, mockErr.Error())
|
||||
s.Require().Equal(expected, actual)
|
||||
})
|
||||
|
||||
s.Run("Fail to unarchive when team and channel not provided", func() {
|
||||
@@ -1891,13 +1891,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
|
||||
args := []string{":"}
|
||||
|
||||
err := unarchiveChannelsCmdF(s.client, cmd, args)
|
||||
s.Require().Nil(err)
|
||||
expectedError := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
|
||||
s.Require().ErrorContains(err, expectedError)
|
||||
s.Require().Equal(expectedError, printer.GetErrorLines()[0])
|
||||
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
|
||||
actual := printer.GetErrorLines()[0]
|
||||
expected := fmt.Sprintf("Unable to find channel '%s'", args[0])
|
||||
s.Require().Equal(expected, actual)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user