Includes mmctl into the mono-repo (#23091)

* Includes mmctl into the mono-repo

* Update to use the new public module paths

* Adds docs check to the mmctl CI

* Fix public utils import path

* Tidy up modules

* Fix linter

* Update CI tasks to use the new file structure

* Update CI references
Этот коммит содержится в:
Miguel de la Cruz
2023-06-05 12:42:55 +02:00
коммит произвёл GitHub
родитель 412109b02e
Коммит 951456c780
305 изменённых файлов: 47027 добавлений и 88 удалений

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

@@ -0,0 +1,50 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"io/ioutil"
"net"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestCheckValidSocket(t *testing.T) {
t.Run("should return error if the file is not a socket", func(t *testing.T) {
f, err := ioutil.TempFile(os.TempDir(), "mmctl_socket_")
require.NoError(t, err)
defer os.Remove(f.Name())
require.NoError(t, os.Chmod(f.Name(), 0600))
require.Error(t, checkValidSocket(f.Name()))
})
t.Run("should return error if the file has not the right permissions", func(t *testing.T) {
f, err := ioutil.TempFile(os.TempDir(), "mmctl_socket_")
require.NoError(t, err)
require.NoError(t, os.Remove(f.Name()))
s, err := net.Listen("unix", f.Name())
require.NoError(t, err)
defer s.Close()
require.NoError(t, os.Chmod(f.Name(), 0777))
require.Error(t, checkValidSocket(f.Name()))
})
t.Run("should return nil if the file is a socket and has the right permissions", func(t *testing.T) {
f, err := ioutil.TempFile(os.TempDir(), "mmctl_socket_")
require.NoError(t, err)
require.NoError(t, os.Remove(f.Name()))
s, err := net.Listen("unix", f.Name())
require.NoError(t, err)
defer s.Close()
require.NoError(t, os.Chmod(f.Name(), 0600))
require.NoError(t, checkValidSocket(f.Name()))
})
}