forked from quickfixgo/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
filestore_test.go
50 lines (41 loc) · 1.4 KB
/
filestore_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
package quickfix
import (
"fmt"
"os"
"path"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
// FileStoreTestSuite runs all tests in the MessageStoreTestSuite against the FileStore implementation
type FileStoreTestSuite struct {
MessageStoreTestSuite
fileStoreRootPath string
}
func (suite *FileStoreTestSuite) SetupTest() {
suite.fileStoreRootPath = path.Join(os.TempDir(), fmt.Sprintf("FileStoreTestSuite-%d", os.Getpid()))
fileStorePath := path.Join(suite.fileStoreRootPath, fmt.Sprintf("%d", time.Now().UnixNano()))
sessionID := SessionID{BeginString: "FIX.4.4", SenderCompID: "SENDER", TargetCompID: "TARGET"}
// create settings
settings, err := ParseSettings(strings.NewReader(fmt.Sprintf(`
[DEFAULT]
FileStorePath=%s
[SESSION]
BeginString=%s
SenderCompID=%s
TargetCompID=%s`, fileStorePath, sessionID.BeginString, sessionID.SenderCompID, sessionID.TargetCompID)))
require.Nil(suite.T(), err)
// create store
backupStore := &backupStoreFactory{messagesQueue: make(chan *BackupMessage, 100), backupFactory: NewMemoryStoreFactory()}
suite.msgStore, err = NewFileStoreFactory(settings, backupStore).Create(sessionID)
require.Nil(suite.T(), err)
}
func (suite *FileStoreTestSuite) TearDownTest() {
suite.msgStore.Close()
os.RemoveAll(suite.fileStoreRootPath)
}
func TestFileStoreTestSuite(t *testing.T) {
suite.Run(t, new(FileStoreTestSuite))
}