File tree Expand file tree Collapse file tree 5 files changed +68
-4
lines changed Expand file tree Collapse file tree 5 files changed +68
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ module testsuites
2
2
3
3
go 1.17
4
4
5
- require github.com/smacker/go-tree-sitter v0.0.0-20211116060328-db7fde9b5e82
5
+ require (
6
+ github.com/smacker/go-tree-sitter v0.0.0-20211116060328-db7fde9b5e82
7
+ github.com/stretchr/testify v1.4.0
8
+ )
6
9
7
- require gopkg.in/yaml.v2 v2.4.0 // indirect
10
+ require (
11
+ github.com/davecgh/go-spew v1.1.0 // indirect
12
+ github.com/pmezard/go-difflib v1.0.0 // indirect
13
+ gopkg.in/yaml.v2 v2.4.0
14
+ )
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ github.com/smacker/go-tree-sitter v0.0.0-20211116060328-db7fde9b5e82/go.mod h1:E
7
7
github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
8
8
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk =
9
9
github.com/stretchr/testify v1.4.0 /go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4 =
10
+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM =
10
11
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 /go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0 =
11
- gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw =
12
12
gopkg.in/yaml.v2 v2.2.2 /go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI =
13
13
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY =
14
14
gopkg.in/yaml.v2 v2.4.0 /go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ =
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ func main() {
27
27
config := NewConfig ()
28
28
29
29
crawlRepoBehaviorsAndSaveToJSON (config )
30
- crawlSingleFileForMethods ("../repo-to-crawl/system/subsystem/file.go" ) // // ex: ../repo-to-crawl/venus-gateway/proofevent/proof_event.go
31
30
}
32
31
33
32
func crawlRepoBehaviorsAndSaveToJSON (config Config ) {
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "context"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ func TestExtractPublicMethodsFromFile (t * testing.T ) {
11
+ fnsAnn , err := extractPublicMethodsFromFile (context .Background (), "./mocks/event.go" )
12
+ if err != nil {
13
+ t .Errorf ("got error: %v" , err .Error ())
14
+ }
15
+
16
+ if len (fnsAnn ) != 2 {
17
+ t .Errorf ("got %q, expected %q methods" , len (fnsAnn ), 2 )
18
+ }
19
+
20
+ assert .Equal (t , "HelloEvent" , fnsAnn [0 ].Name )
21
+ assert .Equal (t , "()" , fnsAnn [0 ].InputParams ) // input param
22
+ assert .Equal (t , "string" , fnsAnn [0 ].ReturnValues ) // return param
23
+
24
+ assert .Equal (t , "HelloEventWithParameter" , fnsAnn [1 ].Name )
25
+ assert .Equal (t , "(param string)" , fnsAnn [1 ].InputParams )
26
+ assert .Equal (t , "(string, error)" , fnsAnn [1 ].ReturnValues )
27
+ }
Original file line number Diff line number Diff line change
1
+ package mocks
2
+
3
+ import (
4
+ "errors"
5
+ "fmt"
6
+ "time"
7
+ )
8
+
9
+ type Event struct {
10
+ ID string `json:"id"`
11
+ }
12
+
13
+ func NewEvent () * Event {
14
+ return & Event {
15
+ ID : time .Now ().String (),
16
+ }
17
+ }
18
+
19
+ // HelloEvent simple method that just formats message.
20
+ func (e * Event ) HelloEvent () string {
21
+ return fmt .Sprintf ("Simple HelloEvent" )
22
+ }
23
+
24
+ // HelloEventWithParameter accepts one param that got formated in message.
25
+ func (e * Event ) HelloEventWithParameter (param string ) (string , error ) {
26
+ if param == "" {
27
+ return "" , errors .New ("no param provided" )
28
+ }
29
+
30
+ return fmt .Sprintf ("HelloEventWithParameter: %v" , param ), nil
31
+ }
You can’t perform that action at this time.
0 commit comments