Rename http integration tests to transport

This commit is contained in:
Adam Ryman 2016-10-28 17:10:18 -07:00
Родитель cfdfbfb6a5
Коммит 2182e790ce
5 изменённых файлов: 26 добавлений и 30 удалений

Просмотреть файл

@ -3,24 +3,24 @@ OK_COLOR=\e[38;5;118m
UNDER=\n________________________________________________________________________________\n
END_COLOR_LINE=$(UNDER)$(NO_COLOR)
HTTPTEST_MSG=\n$(OK_COLOR)Starting http end to end test:$(END_COLOR_LINE)
TRANSPORT_TEST_MSG=\n$(OK_COLOR)Starting transport end to end test:$(END_COLOR_LINE)
CLITEST_MSG=\n$(OK_COLOR)Start server and cliclient generate, build, and run test:$(END_COLOR_LINE)
CLI_TEST_MSG=\n$(OK_COLOR)Start server and cliclient generate, build, and run test:$(END_COLOR_LINE)
all: test
test: clean test-http test-cli
test: clean test-transport test-cli
test-http:
@printf '$(HTTPTEST_MSG)'
$(MAKE) -C http
test-transport:
@printf '$(TRANSPORT_TEST_MSG)'
$(MAKE) -C transport
test-cli:
@printf '$(CLITEST_MSG)'
@printf '$(CLI_TEST_MSG)'
go test -v ./cli
clean:
go test ./cli -clean
$(MAKE) -C http clean
$(MAKE) -C transport clean

Просмотреть файл

@ -5,7 +5,7 @@ END_COLOR_LINE=$(UNDER)$(NO_COLOR)
TRUSS_MSG=\n$(OK_COLOR)Running Truss...$(END_COLOR_LINE)
TEST_RUNNING_MSG=\n$(OK_COLOR)Running http tests:$(END_COLOR_LINE)
TEST_RUNNING_MSG=\n$(OK_COLOR)Running transport tests:$(END_COLOR_LINE)
TRUSS_AGAIN_MSG=\n$(OK_COLOR)Running Truss... again, to test regeneration$(END_COLOR_LINE)
@ -13,16 +13,15 @@ all: test
test:
@echo -e '$(TRUSS_MSG)'
truss httptest.proto
cp -r handlers httptest-service
truss transport-test.proto
cp -r handlers transport-service
@echo -e '$(TEST_RUNNING_MSG)'
go test -v
@echo -e '$(TRUSS_AGAIN_MSG)'
truss httptest.proto
truss transport-test.proto
@echo -e '$(TEST_RUNNING_MSG)'
go test -v
$(MAKE) clean
clean:
rm -rf httptest-service
rm -rf third_party
rm -rf transport-service

Просмотреть файл

@ -12,18 +12,18 @@ import (
_ "github.com/go-kit/kit/log"
_ "github.com/go-kit/kit/metrics"
pb "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service"
pb "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service"
)
// NewService returns a naïve, stateless implementation of Service.
func NewService() Service {
return httptestService{}
return transportService{}
}
type httptestService struct{}
type transportService struct{}
// GetWithQuery implements Service.
func (s httptestService) GetWithQuery(ctx context.Context, in *pb.GetWithQueryRequest) (*pb.GetWithQueryResponse, error) {
func (s transportService) GetWithQuery(ctx context.Context, in *pb.GetWithQueryRequest) (*pb.GetWithQueryResponse, error) {
response := pb.GetWithQueryResponse{
V: in.A + in.B,
}
@ -32,7 +32,7 @@ func (s httptestService) GetWithQuery(ctx context.Context, in *pb.GetWithQueryRe
}
// GetWithRepeatedQuery implements Service.
func (s httptestService) GetWithRepeatedQuery(ctx context.Context, in *pb.GetWithRepeatedQueryRequest) (*pb.GetWithRepeatedQueryResponse, error) {
func (s transportService) GetWithRepeatedQuery(ctx context.Context, in *pb.GetWithRepeatedQueryRequest) (*pb.GetWithRepeatedQueryResponse, error) {
var out int64
for _, v := range in.A {
@ -47,7 +47,7 @@ func (s httptestService) GetWithRepeatedQuery(ctx context.Context, in *pb.GetWit
}
// PostWithNestedMessageBody implements Service.
func (s httptestService) PostWithNestedMessageBody(ctx context.Context, in *pb.PostWithNestedMessageBodyRequest) (*pb.PostWithNestedMessageBodyResponse, error) {
func (s transportService) PostWithNestedMessageBody(ctx context.Context, in *pb.PostWithNestedMessageBodyRequest) (*pb.PostWithNestedMessageBodyResponse, error) {
response := pb.PostWithNestedMessageBodyResponse{
V: in.NM.A + in.NM.B,
}
@ -55,7 +55,7 @@ func (s httptestService) PostWithNestedMessageBody(ctx context.Context, in *pb.P
}
// CtxtToCtxtViaHTTPHeader implements Service.
func (s httptestService) CtxToCtxViaHTTPHeader(ctx context.Context, in *pb.HeaderRequest) (*pb.HeaderResponse, error) {
func (s transportService) CtxToCtxViaHTTPHeader(ctx context.Context, in *pb.HeaderRequest) (*pb.HeaderResponse, error) {
var resp pb.HeaderResponse
val := ctx.Value(in.HeaderKey)

Просмотреть файл

@ -6,7 +6,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
@ -19,18 +18,16 @@ import (
"github.com/go-kit/kit/log"
// This Service
pb "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service"
svc "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service/generated"
httpclient "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service/generated/client/http"
handler "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service/handlers/server"
pb "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service"
svc "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/generated"
httpclient "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/generated/client/http"
handler "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/handlers/server"
"github.com/pkg/errors"
)
var httpserver *httptest.Server
var _ = io.Copy
func init() {
var logger log.Logger
logger = log.NewNopLogger()

Просмотреть файл

@ -1,10 +1,10 @@
syntax = "proto3";
package httptest;
package transport;
import "google/api/annotations.proto";
service HTTPPermutations {
service TransportPermutations {
rpc GetWithQuery (GetWithQueryRequest) returns (GetWithQueryResponse) {
option (google.api.http) = {
get: "/getwithquery"