Skip to content

Commit 220c30e

Browse files
committed
Improve test
1 parent 5b18efc commit 220c30e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

main_test.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"path"
77
"runtime"
8+
"strings"
89
"testing"
910

1011
"github.com/yoozoo/protoapi/cmd"
@@ -18,17 +19,17 @@ func init() {
1819
if err != nil {
1920
panic(err)
2021
}
22+
23+
go serv()
2124
}
22-
func TestCmd(t *testing.T) {
25+
26+
func test(t *testing.T, args string) {
27+
println(args)
2328
cli := cmd.RootCmd
2429
buf := new(bytes.Buffer)
2530
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, " "))
3233

3334
err := cli.Execute()
3435
if err != nil {
@@ -37,3 +38,17 @@ func TestCmd(t *testing.T) {
3738

3839
println(buf.String())
3940
}
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

Comments
 (0)