5
5
"os"
6
6
"path"
7
7
"runtime"
8
+ "strings"
8
9
"testing"
9
10
10
11
"github.com/yoozoo/protoapi/cmd"
@@ -18,17 +19,17 @@ func init() {
18
19
if err != nil {
19
20
panic (err )
20
21
}
22
+
23
+ go serv ()
21
24
}
22
- func TestCmd (t * testing.T ) {
25
+
26
+ func test (t * testing.T , args string ) {
27
+ println (args )
23
28
cli := cmd .RootCmd
24
29
buf := new (bytes.Buffer )
25
30
cli .SetOutput (buf )
26
- cli .SetArgs ([]string {
27
- "gen" , "--lang=go" , "test/result/go" , "test/proto/test.proto" ,
28
- })
29
- // cli.SetArgs([]string{
30
- // "help",
31
- // })
31
+
32
+ cli .SetArgs (strings .Split (args , " " ))
32
33
33
34
err := cli .Execute ()
34
35
if err != nil {
@@ -37,3 +38,17 @@ func TestCmd(t *testing.T) {
37
38
38
39
println (buf .String ())
39
40
}
41
+
42
+ func TestCmd (t * testing.T ) {
43
+ test (t , "gen --lang=go test/result/go test/proto/test.proto" )
44
+ // test(t, "gen --lang=go test/result/go test/proto/calc.proto")
45
+ // test(t, "gen --lang=go test/result/go test/proto/todolist.proto")
46
+ // test(t, "gen --lang=go test/result/go test/proto/nested.proto")
47
+
48
+ test (t , "gen --lang=ts test/result/ts test/proto/test.proto" )
49
+ test (t , "gen --lang=spring test/result/ test/proto/test.proto" )
50
+
51
+ test (t , "gen --lang=phpclient test/result/ test/proto/test.proto" )
52
+ test (t , "gen --lang=yii2 test/result/ test/proto/todolist.proto" )
53
+ test (t , "gen --lang=markdown test/result/ test/proto/login.proto" )
54
+ }
0 commit comments