MM-11272 Add OpenGraph and image dimension metadata to posts (#9313)
* Move OpenGraph code into its own file * Move OpenGraph image proxying to app layer * Move test file code out of api4 package * MM-11272 Add OpenGraph and image dimension metadata to posts
Этот коммит содержится в:
29
utils/testutils/testutils.go
Обычный файл
29
utils/testutils/testutils.go
Обычный файл
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package testutils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func ReadTestFile(name string) ([]byte, error) {
|
||||
path, _ := utils.FindDir("tests")
|
||||
file, err := os.Open(filepath.Join(path, name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
data := &bytes.Buffer{}
|
||||
if _, err := io.Copy(data, file); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return data.Bytes(), nil
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user