mattermost/server/cmd/mmctl/commands/logs_e2e_test.go
Agniva De Sarker efaa6264cc
MM-53032: Fix module path after repo rename (#23689)
It was a good decision in hindsight to keep the public module as 0.x
because this would have been a breaking change again.

https://mattermost.atlassian.net/browse/MM-53032
```release-note
Changed the Go module path from github.com/mattermost/mattermost-server/server/v8 to github.com/mattermost/mattermost/server/v8.

For the public facing module, it's path is also changed from github.com/mattermost/mattermost-server/server/public to github.com/mattermost/mattermost/server/public
```
2023-06-11 10:54:35 +05:30

44 lines
1.1 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
"github.com/spf13/cobra"
)
func (s *MmctlE2ETestSuite) TestlogsCmdF() {
s.SetupTestHelper().InitBasic()
s.RunForSystemAdminAndLocal("Display single log line", func(c client.Client) {
cmd := &cobra.Command{}
cmd.Flags().Int("number", 1, "")
data, err := testLogsCmdF(c, cmd, []string{})
s.Require().Nil(err)
s.Require().Len(data, 2)
})
s.RunForSystemAdminAndLocal("Display in logrus for formatting", func(c client.Client) {
cmd := &cobra.Command{}
cmd.Flags().Bool("logrus", true, "")
cmd.Flags().Int("number", 1, "")
data, err := testLogsCmdF(c, cmd, []string{})
s.Require().Nil(err)
s.Require().Len(data, 2)
s.Contains(data[1], "time=")
s.Contains(data[1], "level=")
s.Contains(data[1], "msg=")
})
s.Run("Should not allow normal user to retrieve logs", func() {
cmd := &cobra.Command{}
cmd.Flags().Int("number", 1, "")
_, err := testLogsCmdF(s.th.Client, cmd, []string{})
s.Require().Error(err)
})
}