-
Notifications
You must be signed in to change notification settings - Fork 0
/
enterprise_test.go
121 lines (82 loc) · 2.17 KB
/
enterprise_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package enterprise
import (
"github.com/stretchr/testify/suite"
"github.com/v8platform/errors"
"github.com/v8platform/runner"
"io/ioutil"
"os"
"path"
"testing"
)
var pwd, _ = os.Getwd()
func NewFileIB(path string) TempInfobase {
ib := TempInfobase{
File: path,
}
return ib
}
type TempInfobase struct {
File string
}
func (ib TempInfobase) Path() string {
return ib.File
}
func (ib TempInfobase) ConnectionString() string {
return "/F" + ib.File
}
func (ib TempInfobase) Values() []string {
return []string{"file=" + ib.File}
}
type TempCreateInfobase struct {
}
func (ib TempCreateInfobase) Command() string {
return "CREATEINFOBASE"
}
func (ib TempCreateInfobase) Check() error {
return nil
}
func (ib TempCreateInfobase) Values() []string {
return []string{}
}
type EnterpriseTestSuite struct {
suite.Suite
TempIB string
}
func TestEnterprise(t *testing.T) {
suite.Run(t, new(EnterpriseTestSuite))
}
func (t *EnterpriseTestSuite) AfterTest(suite, testName string) {
t.ClearTempInfoBase()
}
func (t *EnterpriseTestSuite) BeforeTest(suite, testName string) {
t.CreateTempInfoBase()
}
func (t *EnterpriseTestSuite) SetupSuite() {
ibPath, _ := ioutil.TempDir("", "1c_DB_")
t.TempIB = ibPath
}
func (t *EnterpriseTestSuite) CreateTempInfoBase() {
ib := TempInfobase{File: t.TempIB}
err := runner.Run(ib, TempCreateInfobase{},
runner.WithTimeout(30))
t.Require().NoError(err, errors.GetErrorContext(err))
}
func (t *EnterpriseTestSuite) ClearTempInfoBase() {
err := os.RemoveAll(t.TempIB)
t.Require().NoError(err, errors.GetErrorContext(err))
}
func (t *EnterpriseTestSuite) TestRunEpf() {
epf := path.Join(pwd, "tests", "fixtures", "epf", "Test_Close.epf")
err := runner.Run(NewFileIB(t.TempIB), ExecuteOptions{
File: epf},
runner.WithTimeout(30))
t.Require().NoError(err, errors.GetErrorContext(err))
}
func (t *EnterpriseTestSuite) TestRunWithParam() {
epf := path.Join(pwd, "tests", "fixtures", "epf", "Test_Close.epf")
exec := ExecuteOptions{
File: epf}.WithParams(map[string]string{"Привет": "мир"})
err := runner.Run(NewFileIB(t.TempIB), exec,
runner.WithTimeout(30))
t.Require().NoError(err, errors.GetErrorContext(err))
}