Skip to content

Commit

Permalink
worked enterprise runner
Browse files Browse the repository at this point in the history
tests
create go mod
  • Loading branch information
khorevaa committed Jun 30, 2020
1 parent f5b5fe1 commit 90fbdc5
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 17 deletions.
11 changes: 5 additions & 6 deletions enterprise.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package enterprise

import (
"fmt"
"github.com/khorevaa/go-v8platform/marshaler"
"github.com/khorevaa/go-v8platform/types"
"github.com/v8platform/marshaler"
"strings"
)

var _ types.Command = (*Enterprise)(nil)
const ENTERPRISE = "ENTERPRISE"

type Enterprise struct {
DisableSplash bool `v8:"/DisableSplash" json:"disable_splash"`
Expand All @@ -31,15 +30,15 @@ type Enterprise struct {
}

func (d Enterprise) Command() string {
return types.COMMAND_ENTERPRISE
return ENTERPRISE
}

func (d Enterprise) Check() error {

return nil
}

func (e Enterprise) Values() *types.Values {
func (e Enterprise) Values() []string {
v, _ := marshaler.Marshal(e)
return v

Expand Down Expand Up @@ -84,7 +83,7 @@ type ExecuteOptions struct {
Params map[string]string `v8:"-" json:"-"`
}

func (e ExecuteOptions) Values() *types.Values {
func (e ExecuteOptions) Values() []string {

if len(e.Params) > 0 {

Expand Down
98 changes: 87 additions & 11 deletions enterprise_test.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,121 @@
package enterprise

import (
"github.com/khorevaa/go-v8platform/errors"
"github.com/khorevaa/go-v8platform/infobase"
"github.com/khorevaa/go-v8platform/runner"
"github.com/khorevaa/go-v8platform/tests"
"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 {
tests.TestSuite
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(t.Pwd, "..", "tests", "fixtures", "epf", "Test_Close.epf")
epf := path.Join(pwd, "tests", "fixtures", "epf", "Test_Close.epf")

err := t.Runner.Run(infobase.NewFileIB(t.TempIB), ExecuteOptions{
err := runner.Run(NewFileIB(t.TempIB), ExecuteOptions{
File: epf},
runner.WithTimeout(30))

t.R().NoError(err, errors.GetErrorContext(err))
t.Require().NoError(err, errors.GetErrorContext(err))

}

func (t *EnterpriseTestSuite) TestRunWithParam() {

epf := path.Join(t.Pwd, "..", "tests", "fixtures", "epf", "Test_Close.epf")
epf := path.Join(pwd, "tests", "fixtures", "epf", "Test_Close.epf")

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

err := t.Runner.Run(infobase.NewFileIB(t.TempIB).WithUC("123"), exec,
err := runner.Run(NewFileIB(t.TempIB), exec,
runner.WithTimeout(30))

t.R().NoError(err, errors.GetErrorContext(err))
t.Require().NoError(err, errors.GetErrorContext(err))

}
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/v8platform/enterprise

go 1.14

require (
github.com/stretchr/testify v1.6.1
github.com/v8platform/errors v0.1.0
github.com/v8platform/marshaler v0.1.1
github.com/v8platform/runner v0.0.0-20200630132946-b282ee2b45e9
)
43 changes: 43 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/khorevaa/go-v8platform v0.0.0-20200604183936-0990660c2e4f h1:XUxIxTBTVeSgdueqHIbC14d7qoa22atzt+t80g9WOak=
github.com/khorevaa/go-v8platform v0.0.0-20200604183936-0990660c2e4f/go.mod h1:4i/ouKapwu2dxlZ5r4TZjBAg7wAfrRQ2bTzS4Yf5X9E=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.11.0/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/v8platform/errors v0.1.0 h1:7167okMmxBb76FA3+irT4LW9KTVura0vhMWnFDMHcZw=
github.com/v8platform/errors v0.1.0/go.mod h1:7tASRzzC2AeE0NrQaYT6qfGO2alI0hW91fpoC3lPbQA=
github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034 h1:tUWtou0ZdFgxfiePSkO9uQGuN+GkrA4nEWDjOb/OqZ8=
github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034/go.mod h1:tfhUIhAlIplptMrqi6I2+ygI4CIsbMwCR1SMQ/4tDC0=
github.com/v8platform/marshaler v0.0.0-20200630110446-ab0bd14c5414/go.mod h1:te7WaUpacxK3+jPl1Q9JtkxdNrgtxyAvmM1f3NFvLz8=
github.com/v8platform/marshaler v0.1.1 h1:fcQIx0c818gYW1W45pP/NPttH8iZdYXjpkcKvaFKKQY=
github.com/v8platform/marshaler v0.1.1/go.mod h1:te7WaUpacxK3+jPl1Q9JtkxdNrgtxyAvmM1f3NFvLz8=
github.com/v8platform/runner v0.0.0-20200630132946-b282ee2b45e9 h1:bSTbddWcKbrXJvhpNudQz/mTlfI+Zvah/+E0OBHvj1Y=
github.com/v8platform/runner v0.0.0-20200630132946-b282ee2b45e9/go.mod h1:k6Uxq8zjwUpcoswG0/OeJ60i91yeMKxBuPAHZbtJrSc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Binary file added tests/fixtures/epf/Test_Close.epf
Binary file not shown.
Binary file added tests/fixtures/epf/Test_Params.epf
Binary file not shown.

0 comments on commit 90fbdc5

Please sign in to comment.