You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
minio/pkgs/storage/fsstorage/fs_storage_test.go

54 lines
1.2 KiB

package fsstorage
import (
"io/ioutil"
"os"
10 years ago
"github.com/minio-io/minio/pkgs/storage"
. "gopkg.in/check.v1"
)
type FileSystemStorageSuite struct{}
10 years ago
var _ = Suite(&FileSystemStorageSuite{})
func makeTempTestDir() (string, error) {
return ioutil.TempDir("/tmp", "minio-test-")
}
10 years ago
func (s *FileSystemStorageSuite) TestFileStoragePutAtRootPath(c *C) {
rootDir, err := makeTempTestDir()
c.Assert(err, IsNil)
defer os.RemoveAll(rootDir)
10 years ago
var storage storage.ObjectStorage
storage = FileSystemStorage{
RootDir: rootDir,
}
storage.Put("path1", []byte("object1"))
// assert object1 was created in correct path
object1, err := storage.Get("path1")
c.Assert(err, IsNil)
c.Assert(string(object1), Equals, "object1")
}
10 years ago
func (s *FileSystemStorageSuite) TestFileStoragePutDirPath(c *C) {
rootDir, err := makeTempTestDir()
c.Assert(err, IsNil)
defer os.RemoveAll(rootDir)
10 years ago
var storage storage.ObjectStorage
storage = FileSystemStorage{
RootDir: rootDir,
}
storage.Put("path1/path2/path3", []byte("object"))
// assert object1 was created in correct path
object1, err := storage.Get("path1/path2/path3")
c.Assert(err, IsNil)
c.Assert(string(object1), Equals, "object")
}