Skip to content

Commit 90fbdc5

Browse files
committed
worked enterprise runner
tests create go mod
1 parent f5b5fe1 commit 90fbdc5

File tree

6 files changed

+145
-17
lines changed

6 files changed

+145
-17
lines changed

enterprise.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ package enterprise
22

33
import (
44
"fmt"
5-
"github.com/khorevaa/go-v8platform/marshaler"
6-
"github.com/khorevaa/go-v8platform/types"
5+
"github.com/v8platform/marshaler"
76
"strings"
87
)
98

10-
var _ types.Command = (*Enterprise)(nil)
9+
const ENTERPRISE = "ENTERPRISE"
1110

1211
type Enterprise struct {
1312
DisableSplash bool `v8:"/DisableSplash" json:"disable_splash"`
@@ -31,15 +30,15 @@ type Enterprise struct {
3130
}
3231

3332
func (d Enterprise) Command() string {
34-
return types.COMMAND_ENTERPRISE
33+
return ENTERPRISE
3534
}
3635

3736
func (d Enterprise) Check() error {
3837

3938
return nil
4039
}
4140

42-
func (e Enterprise) Values() *types.Values {
41+
func (e Enterprise) Values() []string {
4342
v, _ := marshaler.Marshal(e)
4443
return v
4544

@@ -84,7 +83,7 @@ type ExecuteOptions struct {
8483
Params map[string]string `v8:"-" json:"-"`
8584
}
8685

87-
func (e ExecuteOptions) Values() *types.Values {
86+
func (e ExecuteOptions) Values() []string {
8887

8988
if len(e.Params) > 0 {
9089

enterprise_test.go

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,121 @@
11
package enterprise
22

33
import (
4-
"github.com/khorevaa/go-v8platform/errors"
5-
"github.com/khorevaa/go-v8platform/infobase"
6-
"github.com/khorevaa/go-v8platform/runner"
7-
"github.com/khorevaa/go-v8platform/tests"
84
"github.com/stretchr/testify/suite"
5+
"github.com/v8platform/errors"
6+
"github.com/v8platform/runner"
7+
"io/ioutil"
8+
"os"
99
"path"
1010
"testing"
1111
)
1212

13+
var pwd, _ = os.Getwd()
14+
15+
func NewFileIB(path string) TempInfobase {
16+
17+
ib := TempInfobase{
18+
File: path,
19+
}
20+
21+
return ib
22+
}
23+
24+
type TempInfobase struct {
25+
File string
26+
}
27+
28+
func (ib TempInfobase) Path() string {
29+
return ib.File
30+
}
31+
32+
func (ib TempInfobase) ConnectionString() string {
33+
return "/F" + ib.File
34+
}
35+
36+
func (ib TempInfobase) Values() []string {
37+
38+
return []string{"file=" + ib.File}
39+
}
40+
41+
type TempCreateInfobase struct {
42+
}
43+
44+
func (ib TempCreateInfobase) Command() string {
45+
return "CREATEINFOBASE"
46+
}
47+
48+
func (ib TempCreateInfobase) Check() error {
49+
return nil
50+
}
51+
func (ib TempCreateInfobase) Values() []string {
52+
53+
return []string{}
54+
}
55+
1356
type EnterpriseTestSuite struct {
14-
tests.TestSuite
57+
suite.Suite
58+
TempIB string
1559
}
1660

1761
func TestEnterprise(t *testing.T) {
1862
suite.Run(t, new(EnterpriseTestSuite))
1963
}
2064

65+
func (t *EnterpriseTestSuite) AfterTest(suite, testName string) {
66+
t.ClearTempInfoBase()
67+
}
68+
69+
func (t *EnterpriseTestSuite) BeforeTest(suite, testName string) {
70+
t.CreateTempInfoBase()
71+
}
72+
73+
func (t *EnterpriseTestSuite) SetupSuite() {
74+
75+
ibPath, _ := ioutil.TempDir("", "1c_DB_")
76+
t.TempIB = ibPath
77+
78+
}
79+
80+
func (t *EnterpriseTestSuite) CreateTempInfoBase() {
81+
82+
ib := TempInfobase{File: t.TempIB}
83+
84+
err := runner.Run(ib, TempCreateInfobase{},
85+
runner.WithTimeout(30))
86+
87+
t.Require().NoError(err, errors.GetErrorContext(err))
88+
89+
}
90+
91+
func (t *EnterpriseTestSuite) ClearTempInfoBase() {
92+
93+
err := os.RemoveAll(t.TempIB)
94+
t.Require().NoError(err, errors.GetErrorContext(err))
95+
}
96+
2197
func (t *EnterpriseTestSuite) TestRunEpf() {
2298

23-
epf := path.Join(t.Pwd, "..", "tests", "fixtures", "epf", "Test_Close.epf")
99+
epf := path.Join(pwd, "tests", "fixtures", "epf", "Test_Close.epf")
24100

25-
err := t.Runner.Run(infobase.NewFileIB(t.TempIB), ExecuteOptions{
101+
err := runner.Run(NewFileIB(t.TempIB), ExecuteOptions{
26102
File: epf},
27103
runner.WithTimeout(30))
28104

29-
t.R().NoError(err, errors.GetErrorContext(err))
105+
t.Require().NoError(err, errors.GetErrorContext(err))
30106

31107
}
32108

33109
func (t *EnterpriseTestSuite) TestRunWithParam() {
34110

35-
epf := path.Join(t.Pwd, "..", "tests", "fixtures", "epf", "Test_Close.epf")
111+
epf := path.Join(pwd, "tests", "fixtures", "epf", "Test_Close.epf")
36112

37113
exec := ExecuteOptions{
38114
File: epf}.WithParams(map[string]string{"Привет": "мир"})
39115

40-
err := t.Runner.Run(infobase.NewFileIB(t.TempIB).WithUC("123"), exec,
116+
err := runner.Run(NewFileIB(t.TempIB), exec,
41117
runner.WithTimeout(30))
42118

43-
t.R().NoError(err, errors.GetErrorContext(err))
119+
t.Require().NoError(err, errors.GetErrorContext(err))
44120

45121
}

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/v8platform/enterprise
2+
3+
go 1.14
4+
5+
require (
6+
github.com/stretchr/testify v1.6.1
7+
github.com/v8platform/errors v0.1.0
8+
github.com/v8platform/marshaler v0.1.1
9+
github.com/v8platform/runner v0.0.0-20200630132946-b282ee2b45e9
10+
)

go.sum

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
4+
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
5+
github.com/khorevaa/go-v8platform v0.0.0-20200604183936-0990660c2e4f h1:XUxIxTBTVeSgdueqHIbC14d7qoa22atzt+t80g9WOak=
6+
github.com/khorevaa/go-v8platform v0.0.0-20200604183936-0990660c2e4f/go.mod h1:4i/ouKapwu2dxlZ5r4TZjBAg7wAfrRQ2bTzS4Yf5X9E=
7+
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
8+
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
9+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
10+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
11+
github.com/pkg/sftp v1.11.0/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
12+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
13+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
14+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
16+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
17+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
18+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
19+
github.com/v8platform/errors v0.1.0 h1:7167okMmxBb76FA3+irT4LW9KTVura0vhMWnFDMHcZw=
20+
github.com/v8platform/errors v0.1.0/go.mod h1:7tASRzzC2AeE0NrQaYT6qfGO2alI0hW91fpoC3lPbQA=
21+
github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034 h1:tUWtou0ZdFgxfiePSkO9uQGuN+GkrA4nEWDjOb/OqZ8=
22+
github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034/go.mod h1:tfhUIhAlIplptMrqi6I2+ygI4CIsbMwCR1SMQ/4tDC0=
23+
github.com/v8platform/marshaler v0.0.0-20200630110446-ab0bd14c5414/go.mod h1:te7WaUpacxK3+jPl1Q9JtkxdNrgtxyAvmM1f3NFvLz8=
24+
github.com/v8platform/marshaler v0.1.1 h1:fcQIx0c818gYW1W45pP/NPttH8iZdYXjpkcKvaFKKQY=
25+
github.com/v8platform/marshaler v0.1.1/go.mod h1:te7WaUpacxK3+jPl1Q9JtkxdNrgtxyAvmM1f3NFvLz8=
26+
github.com/v8platform/runner v0.0.0-20200630132946-b282ee2b45e9 h1:bSTbddWcKbrXJvhpNudQz/mTlfI+Zvah/+E0OBHvj1Y=
27+
github.com/v8platform/runner v0.0.0-20200630132946-b282ee2b45e9/go.mod h1:k6Uxq8zjwUpcoswG0/OeJ60i91yeMKxBuPAHZbtJrSc=
28+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
29+
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
30+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
31+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
32+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
33+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
34+
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
35+
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
36+
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
37+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
38+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
39+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
40+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
41+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
42+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
43+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

tests/fixtures/epf/Test_Close.epf

5.43 KB
Binary file not shown.

tests/fixtures/epf/Test_Params.epf

5.43 KB
Binary file not shown.

0 commit comments

Comments
 (0)