Browse Source

Improve storage wrapper tests by checking file content

feature/add-storage-layer
Fabian Vowie 3 years ago
parent
commit
44ceaf8582
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 12
      storage/storage_test.go

12
storage/storage_test.go

@ -9,11 +9,11 @@ import (
)
func TestFileSystemStorageProvider(t *testing.T) {
dummyData := []byte{0x13, 0x37}
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",
@ -23,12 +23,15 @@ func TestFileSystemStorageProvider(t *testing.T) {
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin")
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) {
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{
fileSystem: fileSystem,
@ -39,5 +42,8 @@ func TestFileSystemStorageProvider(t *testing.T) {
exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin")
assert.True(t, exists)
content, _ := afero.ReadFile(fileSystem, "/tmp/foo/bar/test/test.bin")
assert.Equal(t, dummyData, content)
})
}
Loading…
Cancel
Save