Skip to content

Commit

Permalink
Merge pull request #508 from uber/lu.ts
Browse files Browse the repository at this point in the history
Make generating tchannel client test server optional
  • Loading branch information
ChuntaoLu committed Oct 30, 2018
2 parents 08c4107 + 081ba9a commit 4066160
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 88 deletions.
35 changes: 19 additions & 16 deletions codegen/module_system.go
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/pkg/errors"
"go.uber.org/thriftrw/compile"
yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
)

// EndpointMeta saves meta data used to render an endpoint.
Expand Down Expand Up @@ -617,19 +617,6 @@ func (g *TChannelClientGenerator) Generate(
)
}

server, err := g.templates.ExecTemplate(
"tchannel_client_test_server.tmpl",
clientMeta,
g.packageHelper,
)
if err != nil {
return nil, errors.Wrapf(
err,
"Error executing TChannel server template for %q",
instance.InstanceName,
)
}

// When it is possible to generate structs for all module types, the
// module system will do this transparently. For now we are opting in
// on a per-generator basis.
Expand All @@ -649,11 +636,27 @@ func (g *TChannelClientGenerator) Generate(

baseName := filepath.Base(instance.Directory)
clientFilePath := baseName + ".go"
serverFilePath := baseName + "_test_server.go"

files := map[string][]byte{
clientFilePath: client,
serverFilePath: server,
}

genTestServer, _ := instance.Config["genTestServer"].(bool)
if genTestServer {
server, err := g.templates.ExecTemplate(
"tchannel_client_test_server.tmpl",
clientMeta,
g.packageHelper,
)
if err != nil {
return nil, errors.Wrapf(
err,
"Error executing TChannel server template for %q",
instance.InstanceName,
)
}
serverFilePath := baseName + "_test_server.go"
files[serverFilePath] = server
}

if dependencies != nil {
Expand Down
72 changes: 0 additions & 72 deletions examples/example-gateway/build/clients/corge/corge_test_server.go

This file was deleted.

1 change: 1 addition & 0 deletions examples/example-gateway/clients/baz/client-config.yaml
Expand Up @@ -29,5 +29,6 @@ config:
URLTest: SimpleService::urlTest
thriftFile: clients/baz/baz.thrift
thriftFileSha: '{{placeholder}}'
genTestServer: true
name: baz
type: tchannel

0 comments on commit 4066160

Please sign in to comment.