Extracting html templates into a library (#16946)

* Extracting html templates into a library

* Moving tests to the right place

* Fixing tests

* Addressing PR review comments

* Addressing PR review comments

* Replacing attomic with RWMutex

* Returning errors as channel for Templates watcher

* Address PR review comments

* Other small fixes

* Simplifying NewWithWatcher

* Addressing PR review comments

* Making error handling on rendering templates more robust

* Fixing tests

* Changing how we return errors

* Fixing shadow variables

* Addressing PR review comments

* Logging errors from the outside of sendNotificationEmail

* Fixing lock in shutdown

* Fixing the resource copy for commands tests temporary directories

* Removing unused import

* A couple of tiny fixes
Этот коммит содержится в:
Jesús Espino
2021-03-12 18:46:43 +01:00
коммит произвёл GitHub
родитель 58dce5930e
Коммит 95b0809850
16 изменённых файлов: 834 добавлений и 604 удалений

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

@@ -38,7 +38,7 @@ type testHelper struct {
// Setup creates an instance of testHelper.
func Setup(t testing.TB) *testHelper {
dir, err := ioutil.TempDir("", "testHelper")
dir, err := testlib.SetupTestResources()
if err != nil {
panic("failed to create temporary directory: " + err.Error())
}
@@ -60,7 +60,7 @@ func Setup(t testing.TB) *testHelper {
// Setup creates an instance of testHelper.
func SetupWithStoreMock(t testing.TB) *testHelper {
dir, err := ioutil.TempDir("", "testHelper")
dir, err := testlib.SetupTestResources()
if err != nil {
panic("failed to create temporary directory: " + err.Error())
}

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

@@ -9,9 +9,6 @@ import (
"testing"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v5/utils"
"github.com/mattermost/mattermost-server/v5/utils/fileutils"
)
func TestConfigFlag(t *testing.T) {
@@ -19,16 +16,14 @@ func TestConfigFlag(t *testing.T) {
defer th.TearDown()
dir := th.TemporaryDirectory()
i18n, ok := fileutils.FindDir("i18n")
require.True(t, ok)
require.NoError(t, utils.CopyDir(i18n, filepath.Join(dir, "i18n")))
prevDir, err := os.Getwd()
require.NoError(t, err)
defer os.Chdir(prevDir)
os.Chdir(dir)
t.Run("version without a config file should fail", func(t *testing.T) {
err := os.RemoveAll("config")
require.NoError(t, err)
th.SetAutoConfig(false)
defer th.SetAutoConfig(true)
require.Error(t, th.RunCommand(t, "version"))