forked from wal-g/wal-g
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands_test.go
31 lines (28 loc) · 977 Bytes
/
commands_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package test
import (
"bytes"
"github.com/stretchr/testify/assert"
"github.com/wal-g/wal-g/internal"
"github.com/wal-g/wal-g/testtools"
"github.com/wal-g/wal-g/utility"
"io/ioutil"
"testing"
)
func TestTryDownloadWALFile_Exist(t *testing.T) {
expectedData := []byte("mock")
folder := testtools.MakeDefaultInMemoryStorageFolder().GetSubFolder(utility.WalPath)
folder.PutObject("00000001000000000000007C", bytes.NewBuffer(expectedData))
archiveReader, exist, err := internal.TryDownloadWALFile(folder, "00000001000000000000007C")
assert.NoError(t, err)
assert.True(t, exist)
actualData, err := ioutil.ReadAll(archiveReader)
assert.NoError(t, err)
assert.Equal(t, expectedData, actualData)
}
func TestTryDownloadWALFile_NotExist(t *testing.T) {
folder := testtools.MakeDefaultInMemoryStorageFolder()
reader, exist, err := internal.TryDownloadWALFile(folder, "00000001000000000000007C")
assert.Nil(t, reader)
assert.False(t, exist)
assert.NoError(t, err)
}