-
Notifications
You must be signed in to change notification settings - Fork 144
/
gengokit_test.go
65 lines (52 loc) · 1.25 KB
/
gengokit_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package gengokit
import (
"os"
"path/filepath"
"testing"
"github.com/metaverse/truss/svcdef"
)
var gopath []string
func init() {
gopath = filepath.SplitList(os.Getenv("GOPATH"))
}
func TestNewData(t *testing.T) {
const def = `
syntax = "proto3";
// General package
package general;
import "github.com/metaverse/truss/deftree/googlethirdparty/annotations.proto";
// RequestMessage is so foo
message RequestMessage {
string input = 1;
}
// ResponseMessage is so bar
message ResponseMessage {
string output = 1;
}
// ProtoService is a service
service ProtoService {
// ProtoMethod is simple. Like a gopher.
rpc ProtoMethod (RequestMessage) returns (ResponseMessage) {
// No {} in path and no body, everything is in the query
option (google.api.http) = {
get: "/route"
};
}
}
`
sd, err := svcdef.NewFromString(def, gopath)
if err != nil {
t.Fatal(err)
}
conf := Config{
GoPackage: "github.com/metaverse/truss/gengokit/general-service",
PBPackage: "github.com/metaverse/truss/gengokit/general-service",
}
te, err := NewData(sd, conf)
if err != nil {
t.Fatal(err)
}
if got, want := te.PackageName, sd.PkgName; got != want {
t.Fatalf("\n`%v` was PackageName\n`%v` was wanted", got, want)
}
}