|
@ -9,11 +9,11 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func TestFileSystemStorageProvider(t *testing.T) { |
|
|
func TestFileSystemStorageProvider(t *testing.T) { |
|
|
|
|
|
dummyData := []byte{0x13, 0x37} |
|
|
|
|
|
|
|
|
t.Run("storeRaw method stores files in filesystem", func(t *testing.T) { |
|
|
t.Run("storeRaw method stores files in filesystem", func(t *testing.T) { |
|
|
fileSystem := afero.NewMemMapFs() |
|
|
fileSystem := afero.NewMemMapFs() |
|
|
|
|
|
|
|
|
dummyData := []byte{0x13, 0x37} |
|
|
|
|
|
|
|
|
|
|
|
provider := FileSystemStorageProvider{ |
|
|
provider := FileSystemStorageProvider{ |
|
|
fileSystem: fileSystem, |
|
|
fileSystem: fileSystem, |
|
|
basePath: "/tmp/foo/bar", |
|
|
basePath: "/tmp/foo/bar", |
|
@ -23,12 +23,15 @@ func TestFileSystemStorageProvider(t *testing.T) { |
|
|
|
|
|
|
|
|
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") |
|
|
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") |
|
|
assert.True(t, exists) |
|
|
assert.True(t, exists) |
|
|
|
|
|
|
|
|
|
|
|
content, _ := afero.ReadFile(fileSystem, "/tmp/foo/bar/test/test.bin") |
|
|
|
|
|
assert.Equal(t, dummyData, content) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
t.Run("storeExisting method stores files in filesystem", func(t *testing.T) { |
|
|
t.Run("storeExisting method stores files in filesystem", func(t *testing.T) { |
|
|
fileSystem := afero.NewMemMapFs() |
|
|
fileSystem := afero.NewMemMapFs() |
|
|
|
|
|
|
|
|
afero.WriteFile(fileSystem, "/tmp/existing.bin", []byte{0x13, 0x37}, os.ModePerm) |
|
|
|
|
|
|
|
|
afero.WriteFile(fileSystem, "/tmp/existing.bin", dummyData, os.ModePerm) |
|
|
|
|
|
|
|
|
provider := FileSystemStorageProvider{ |
|
|
provider := FileSystemStorageProvider{ |
|
|
fileSystem: fileSystem, |
|
|
fileSystem: fileSystem, |
|
@ -39,5 +42,8 @@ func TestFileSystemStorageProvider(t *testing.T) { |
|
|
|
|
|
|
|
|
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") |
|
|
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") |
|
|
assert.True(t, exists) |
|
|
assert.True(t, exists) |
|
|
|
|
|
|
|
|
|
|
|
content, _ := afero.ReadFile(fileSystem, "/tmp/foo/bar/test/test.bin") |
|
|
|
|
|
assert.Equal(t, dummyData, content) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |