@@ -10,6 +10,7 @@ import (
1010 "github.com/linuxsuren/api-testing/pkg/render"
1111 "github.com/linuxsuren/api-testing/pkg/runner"
1212 "github.com/linuxsuren/api-testing/pkg/testing"
13+ "github.com/linuxsuren/api-testing/pkg/version"
1314)
1415
1516type server struct {
@@ -41,6 +42,28 @@ func (s *server) Run(ctx context.Context, task *TestTask) (reply *HelloReply, er
4142 suite = & testing.TestSuite {
4243 Items : []testing.TestCase {* testCase },
4344 }
45+ case "testcaseInSuite" :
46+ if suite , err = testing .ParseFromData ([]byte (task .Data )); err != nil {
47+ return
48+ } else if suite == nil || suite .Items == nil {
49+ err = fmt .Errorf ("no test suite found" )
50+ return
51+ }
52+
53+ var targetTestcase * testing.TestCase
54+ for _ , item := range suite .Items {
55+ if item .Name == task .CaseName {
56+ targetTestcase = & item
57+ break
58+ }
59+ }
60+
61+ if targetTestcase != nil {
62+ suite .Items = []testing.TestCase {* targetTestcase }
63+ } else {
64+ err = fmt .Errorf ("cannot found testcase %s" , task .CaseName )
65+ return
66+ }
4467 default :
4568 err = fmt .Errorf ("not support '%s'" , task .Kind )
4669 return
@@ -77,3 +100,9 @@ func (s *server) Run(ctx context.Context, task *TestTask) (reply *HelloReply, er
77100 reply = & HelloReply {Message : buf .String ()}
78101 return
79102}
103+
104+ // GetVersion returns the version
105+ func (s * server ) GetVersion (ctx context.Context , in * Empty ) (reply * HelloReply , err error ) {
106+ reply = & HelloReply {Message : version .GetVersion ()}
107+ return
108+ }
0 commit comments