Skip to content

Commit aaf5673

Browse files
committed
tests: more tests
1 parent 95fad72 commit aaf5673

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

config_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package v8
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"github.com/v8platform/designer"
6+
"github.com/v8platform/runner"
7+
"reflect"
8+
"testing"
9+
)
10+
11+
func TestLoadCfg(t *testing.T) {
12+
13+
ib := NewFileInfobase("./test_ib")
14+
15+
type args struct {
16+
file string
17+
}
18+
tests := []struct {
19+
name string
20+
args args
21+
want designer.LoadCfgOptions
22+
want_args []string
23+
}{
24+
{
25+
"simple",
26+
args{file: "./1cv8.cf"},
27+
designer.LoadCfgOptions{File: "./1cv8.cf", Designer: designer.NewDesigner()},
28+
[]string{
29+
"DESIGNER",
30+
"/IBConnectionString File='./test_ib';",
31+
"/DisableStartupDialogs",
32+
"/LoadCfg ./1cv8.cf",
33+
},
34+
},
35+
}
36+
for _, tt := range tests {
37+
t.Run(tt.name, func(t *testing.T) {
38+
if got := LoadCfg(tt.args.file); !reflect.DeepEqual(got, tt.want) {
39+
t.Errorf("LoadCfg() = %v, want %v", got, tt.want)
40+
}
41+
42+
v8run := runner.NewPlatformRunner(ib, LoadCfg(tt.args.file))
43+
got := v8run.Args()
44+
45+
for _, arg := range tt.want_args {
46+
assert.Contains(t, got, arg,
47+
"NewPlatformRunner() = %v, want %v", got, arg)
48+
49+
}
50+
51+
})
52+
}
53+
}

enterprise_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package v8
2+
3+
import (
4+
"github.com/v8platform/enterprise"
5+
"reflect"
6+
"testing"
7+
)
8+
9+
func TestExecute(t *testing.T) {
10+
type args struct {
11+
file string
12+
params []map[string]string
13+
}
14+
tests := []struct {
15+
name string
16+
args args
17+
want enterprise.ExecuteOptions
18+
}{
19+
{
20+
"run epf",
21+
args{
22+
file: "./path_to_epf.epf",
23+
params: nil,
24+
},
25+
enterprise.ExecuteOptions{
26+
File: "./path_to_epf.epf",
27+
Params: nil,
28+
},
29+
},
30+
{
31+
"run epf with params",
32+
args{
33+
file: "./path_to_epf.epf",
34+
params: []map[string]string{
35+
{
36+
"param1": "any_string",
37+
"param2": "any_string",
38+
},
39+
},
40+
},
41+
enterprise.ExecuteOptions{
42+
File: "./path_to_epf.epf",
43+
Params: map[string]string{
44+
"param1": "any_string",
45+
"param2": "any_string",
46+
},
47+
},
48+
},
49+
}
50+
for _, tt := range tests {
51+
t.Run(tt.name, func(t *testing.T) {
52+
if got := Execute(tt.args.file, tt.args.params...); !reflect.DeepEqual(got, tt.want) {
53+
t.Errorf("Execute() = %v, want %v", got, tt.want)
54+
}
55+
})
56+
}
57+
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/v8platform/v8
33
go 1.15
44

55
require (
6+
github.com/stretchr/testify v1.6.1
67
github.com/v8platform/designer v0.1.0
78
github.com/v8platform/enterprise v0.1.0
89
github.com/v8platform/errors v0.1.0

0 commit comments

Comments
 (0)