Micro-service for file storage and processing written in Go
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.
|
|
package storage
import ( "os" "testing"
"github.com/spf13/afero" "github.com/stretchr/testify/assert" )
func TestFileSystemStorageProvider(t *testing.T) { t.Run("storeRaw method stores files in filesystem", func(t *testing.T) { fileSystem := afero.NewMemMapFs()
dummyData := []byte{0x13, 0x37}
provider := FileSystemStorageProvider{ fileSystem: fileSystem, basePath: "/tmp/foo/bar", }
provider.storeRaw("test", "test.bin", dummyData)
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") assert.True(t, exists) })
t.Run("storeExisting method stores files in filesystem", func(t *testing.T) { fileSystem := afero.NewMemMapFs()
afero.WriteFile(fileSystem, "/tmp/existing.bin", []byte{0x13, 0x37}, os.ModePerm)
provider := FileSystemStorageProvider{ fileSystem: fileSystem, basePath: "/tmp/foo/bar", }
provider.storeExisting("test", "test.bin", "/tmp/existing.bin")
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") assert.True(t, exists) }) }
|