-
Notifications
You must be signed in to change notification settings - Fork 1
/
provider_redis_test.go
55 lines (50 loc) · 2.22 KB
/
provider_redis_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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package fsEngine
import (
"os"
"testing"
"github.com/fanap-infra/fsEngine/mocks"
"github.com/fanap-infra/fsEngine/internal/constants"
"github.com/fanap-infra/fsEngine/pkg/utils"
"github.com/fanap-infra/log"
"github.com/stretchr/testify/assert"
)
func TestCreateFS_Redis(t *testing.T) {
homePath, err := os.UserHomeDir()
assert.Equal(t, nil, err)
_ = utils.DeleteFile(homePath + "/" + constants.FsPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderBackUpPath)
eventListener := EventsListener{t: t}
redisMock := mocks.NewRedisMock()
_, err = CreateFileSystem(fsID, homePath, fileSizeTest, blockSizeTest,
&eventListener, log.GetScope("test"), &redisMock)
assert.Equal(t, nil, err)
assert.Equal(t, true, utils.FileExists(homePath+"/"+constants.FsPath))
assert.Equal(t, true, utils.FileExists(homePath+"/"+constants.HeaderPath))
// assert.Equal(t, true, utils.FileExists(homePath+"/"+constants.HeaderBackUpPath))
size, err := utils.FileSize(homePath + "/" + constants.FsPath)
assert.Equal(t, nil, err)
assert.Equal(t, int64(fileSizeTest), size)
_ = utils.DeleteFile(homePath + "/" + constants.FsPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderBackUpPath)
}
func TestParseFS_Redis(t *testing.T) {
homePath, err := os.UserHomeDir()
assert.Equal(t, nil, err)
_ = utils.DeleteFile(homePath + "/" + constants.FsPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderBackUpPath)
eventListener := EventsListener{t: t}
redisMock := mocks.NewRedisMock()
_, err = CreateFileSystem(fsID, homePath, fileSizeTest, blockSizeTest,
&eventListener, log.GetScope("test"), &redisMock)
assert.Equal(t, nil, err)
fs, err := ParseFileSystem(fsID, homePath, &eventListener, log.GetScope("test"), &redisMock)
assert.Equal(t, nil, err)
assert.Equal(t, fs.blockSize, uint32(blockSizeTest))
assert.Equal(t, fs.maxNumberOfBlocks, uint32(fileSizeTest/blockSizeTest))
_ = utils.DeleteFile(homePath + "/" + constants.FsPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderPath)
_ = utils.DeleteFile(homePath + "/" + constants.HeaderBackUpPath)
}