From ef597f6fe45cae8b3ba405ff89f5b20bfbf349e5 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 7 Dec 2017 15:56:14 -0500 Subject: PLT-8314: Test Message Export Against S3 Bucket (#7957) * Removed export directory config setting, in favour of hard-coding it to an 'export' directory under the local file directory. Improved the local file backend copy implementation to implicitly create the destination directory if it's missing * Fixed the tests --- utils/file_backend_test.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'utils/file_backend_test.go') diff --git a/utils/file_backend_test.go b/utils/file_backend_test.go index 098f86bbd..76cd1f4a8 100644 --- a/utils/file_backend_test.go +++ b/utils/file_backend_test.go @@ -51,9 +51,9 @@ func TestS3FileBackendTestSuite(t *testing.T) { suite.Run(t, &FileBackendTestSuite{ settings: model.FileSettings{ DriverName: model.NewString(model.IMAGE_DRIVER_S3), - AmazonS3AccessKeyId: "minioaccesskey", - AmazonS3SecretAccessKey: "miniosecretkey", - AmazonS3Bucket: "mattermost-test", + AmazonS3AccessKeyId: model.MINIO_ACCESS_KEY, + AmazonS3SecretAccessKey: model.MINIO_SECRET_KEY, + AmazonS3Bucket: model.MINIO_BUCKET, AmazonS3Endpoint: s3Endpoint, AmazonS3SSL: model.NewBool(false), }, @@ -106,6 +106,26 @@ func (s *FileBackendTestSuite) TestCopyFile() { s.Nil(err) } +func (s *FileBackendTestSuite) TestCopyFileToDirectoryThatDoesntExist() { + b := []byte("test") + path1 := "tests/" + model.NewId() + path2 := "tests/newdirectory/" + model.NewId() + + err := s.backend.WriteFile(b, path1) + s.Nil(err) + defer s.backend.RemoveFile(path1) + + err = s.backend.CopyFile(path1, path2) + s.Nil(err) + defer s.backend.RemoveFile(path2) + + _, err = s.backend.ReadFile(path1) + s.Nil(err) + + _, err = s.backend.ReadFile(path2) + s.Nil(err) +} + func (s *FileBackendTestSuite) TestMoveFile() { b := []byte("test") path1 := "tests/" + model.NewId() -- cgit v1.2.3-1-g7c22