-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrunner_test.go
160 lines (116 loc) · 4.39 KB
/
runner_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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package runner
import (
"context"
"fmt"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/v8platform/marshaler"
"io/ioutil"
"os"
"testing"
)
type runTestSuite struct {
suite.Suite
}
func (b *runTestSuite) SetupSuite() {
}
func (s *runTestSuite) r() *require.Assertions {
return s.Require()
}
type v8runnerTestSuite struct {
runTestSuite
}
func Test_runnerTestSuite(t *testing.T) {
suite.Run(t, new(v8runnerTestSuite))
}
func (t *v8runnerTestSuite) TestCmdRunnerCreateInfobase() {
runner := NewPlatformRunner(testInfoBase{}, CreateFileInfoBaseOptions{
File: "./file_ib",
DBFormat: "8.3.8",
})
args := runner.Args()
t.r().Contains(args, CreateInfobase)
t.r().Contains(args, "File='./file_ib';DBFormat=8.3.8")
}
func (t *v8runnerTestSuite) TestCmdRunnerV8path() {
if testing.Short() {
t.T().Skip("skipping test in short mode.")
}
path, _ := ioutil.TempDir("", "1c_DB_")
runner := NewPlatformRunner(testInfoBase{}, CreateFileInfoBaseOptions{
File: path,
})
args := runner.Args()
t.r().Contains(args, CreateInfobase)
t.r().Contains(args, fmt.Sprintf("File='%s'", path))
err := runner.Run(context.Background())
t.r().NoError(err, "no error command")
}
func Exists(name string) (bool, error) {
_, err := os.Stat(name)
if os.IsNotExist(err) {
return false, err
}
return true, nil
}
func NewTempIB() testInfoBase {
path, _ := ioutil.TempDir("", "1c_DB_")
ib := testInfoBase{
File: path,
}
return ib
}
type testInfoBase struct {
// имя каталога, в котором размещается файл информационной базы;
File string `v8:"File, equal_sep, quotes" json:"file"`
// язык (страна), который будет использован при открытии или создании информационной базы.
// Допустимые значения такие же как у параметра <Форматная строка> метода Формат().
// Параметр Locale задавать не обязательно.
// Если не задан, то будут использованы региональные установки текущей информационной базы;
Locale string `v8:"Locale, optional, equal_sep" json:"locale"`
}
func (d testInfoBase) ConnectionString() string {
return "File=" + d.File
}
type CreateInfoBaseOptions struct {
DisableStartupDialogs bool `v8:"/DisableStartupDialogs" json:"disable_startup_dialogs"`
UseTemplate string `v8:"/UseTemplate" json:"use_template"`
AddToList bool `v8:"/AddToList" json:"add_to_list"`
}
type CreateFileInfoBaseOptions struct {
CreateInfoBaseOptions `v8:",inherit" json:"common"`
// имя каталога, в котором размещается файл информационной базы;
File string `v8:"File, equal_sep, quotes" json:"file"`
// язык (страна), который будет использован при открытии или создании информационной базы.
// Допустимые значения такие же как у параметра <Форматная строка> метода Формат().
// Параметр Locale задавать не обязательно.
// Если не задан, то будут использованы региональные установки текущей информационной базы;
Locale string `v8:"Locale, optional, equal_sep" json:"locale"`
// формат базы данных
// Допустимые значения: 8.2.14, 8.3.8.
// Значение по умолчанию — 8.2.14
DBFormat string `v8:"DBFormat, optional, equal_sep" json:"db_format"`
// размер страницы базы данных в байтах
// Допустимые значения:
// 4096(или 4k),
// 8192(или 8k),
// 16384(или 16k),
// 32768(или 32k),
// 65536(или 64k),
// Значение по умолчанию — 4k
DBPageSize int64 `v8:"DBPageSize, optional, equal_sep" json:"db_page_size"`
}
func (d CreateInfoBaseOptions) Command() string {
return CreateInfobase
}
func (d CreateInfoBaseOptions) Check() error {
return nil
}
func (d CreateInfoBaseOptions) Values() []string {
v, _ := marshaler.Marshal(d)
return v
}
func (d CreateFileInfoBaseOptions) Values() []string {
v, _ := marshaler.Marshal(d)
return v
}