Skip to content

Commit

Permalink
new: new infobase interface && tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khorevaa committed Nov 20, 2020
1 parent 1d595a6 commit 88b1285
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
9 changes: 3 additions & 6 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,11 @@ func getCmdArgs(where Infobase, what Command, options Options) []string {

if isCreateInfobase(what) {

whereParams, whereValues := getConnectionsStringParams(where.Values())
whatParams, whatValues := getConnectionsStringParams(what.Values())

connectionString := joinConnectionStringParams(whatParams, whereParams)
connectionStringParams, values := getConnectionsStringParams(what.Values())

connectionString := strings.Join(connectionStringParams, ";")
params.Append(connectionString)
params.Append(whatValues...)
params.Append(whereValues...)
params.Append(values...)

} else {

Expand Down
30 changes: 9 additions & 21 deletions runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/v8platform/marshaler"
"io/ioutil"
"os"
"path"
"testing"
)

Expand All @@ -30,15 +29,16 @@ func Test_runnerTestSuite(t *testing.T) {
suite.Run(t, new(v8runnerTestSuite))
}

func (t *v8runnerTestSuite) TestCmdRunner() {
func (t *v8runnerTestSuite) TestCmdRunnerCreateInfobase() {

tempIB := NewTempIB()
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")

err := Run(tempIB, CreateFileInfoBaseOptions{})
t.r().NoError(err)
fileBaseCreated, err2 := Exists(path.Join(tempIB.File, "1Cv8.1CD"))
t.r().NoError(err2)
t.r().True(fileBaseCreated, "Файл базы должен быть создан")
}

func Exists(name string) (bool, error) {
Expand Down Expand Up @@ -72,21 +72,9 @@ type testInfoBase struct {
Locale string `v8:"Locale, optional, equal_sep" json:"locale"`
}

func (d testInfoBase) Path() string {

return d.File
}

func (d testInfoBase) Values() []string {

v, _ := marshaler.Marshal(d)
return v

}

func (d testInfoBase) ConnectionString() string {

return "/F " + d.File
return "File=" + d.File

}

Expand Down
2 changes: 0 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ type Param interface {
}

type Infobase interface {
Path() string
// Возвращает
// - /IBConnectionString <СтрокаПодключения>
// - /F<ПУтьКБазе>
// - /S<ПутьКСервернойБазе>
ConnectionString() string
Values() []string
}

type Command interface {
Expand Down

0 comments on commit 88b1285

Please sign in to comment.