mattermost/utils/testutils/testutils.go
Agniva De Sarker 2db6823f5d Refactor more code to use testutils.WasCalled (#13054)
* Refactor more code to use testutils.WasCalled

* incorporate review comments

* Revert watcher_test.go changes

The file is in config package and the other tests use config_test.
So it is not visible.
2019-11-13 16:11:26 +08:00

29 lines
571 B
Go

// 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/fileutils"
)
func ReadTestFile(name string) ([]byte, error) {
path, _ := fileutils.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
}
}