Skip to content

Commit

Permalink
Move testdata protos under internal/ and use more compatible paths. (#65
Browse files Browse the repository at this point in the history
)

* Move testdata protos under internal/ and use more compatible paths.

* Add stub files in testdata dirs (for Go 1.13)
  • Loading branch information
jmillikin-stripe committed Oct 3, 2019
1 parent c7a2dc2 commit 40659e5
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 150 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Expand Up @@ -19,9 +19,12 @@ install:
- export PATH="${TRAVIS_HOME}/third_party/protobuf-${PROTOC_VERSION}/bin:${PATH}"
- go get github.com/golang/protobuf/protoc-gen-go
- go get github.com/gogo/protobuf/protoc-gen-gogofast
- ( cd testdata && wget https://raw.githubusercontent.com/gogo/protobuf/v1.1.1/gogoproto/gogo.proto )
- protoc --go_out="${TRAVIS_HOME}/gopath/src" --proto_path=testdata test_proto_v2.proto test_proto_v3.proto
- protoc --gogofast_out="${TRAVIS_HOME}/gopath/src" --proto_path=testdata test_proto_gogo.proto
- mkdir -p "${TRAVIS_HOME}/protopath/github.com/stripe"
- ln -s "${PWD}" "${TRAVIS_HOME}/protopath/github.com/stripe/skycfg"
- mkdir -p "${TRAVIS_HOME}/protopath/github.com/gogo/protobuf/gogoproto"
- ( cd "${TRAVIS_HOME}/protopath/github.com/gogo/protobuf/gogoproto" && wget https://raw.githubusercontent.com/gogo/protobuf/v1.1.1/gogoproto/gogo.proto )
- protoc --go_out="${TRAVIS_HOME}/gopath/src" --proto_path="${TRAVIS_HOME}/protopath" github.com/stripe/skycfg/internal/testdata/test_proto/test_proto_v2.proto github.com/stripe/skycfg/internal/testdata/test_proto/test_proto_v3.proto
- protoc --gogofast_out="${TRAVIS_HOME}/gopath/src" --proto_path="${TRAVIS_HOME}/protopath" github.com/stripe/skycfg/internal/testdata/test_proto_gogo/test_proto_gogo.proto
- go get -t -v ./...

script:
Expand Down
11 changes: 6 additions & 5 deletions internal/go/skycfg/proto_test.go
Expand Up @@ -39,7 +39,8 @@ import (

descriptorpb "github.com/golang/protobuf/protoc-gen-go/descriptor"

pb "github.com/stripe/skycfg/test_proto"
pb "github.com/stripe/skycfg/internal/testdata/test_proto"
pb_gogo "github.com/stripe/skycfg/internal/testdata/test_proto_gogo"
)

func init() {
Expand Down Expand Up @@ -618,7 +619,7 @@ func TestMessageGogo(t *testing.T) {
f_duration = proto.package("google.protobuf").Duration(seconds = 1),
)`)
gotMsg := val.(*skyProtoMessage).msg
wantMsg := &pb.MessageGogo{
wantMsg := &pb_gogo.MessageGogo{
FInt32: proto.Int32(1010),
FInt64: proto.Int64(1020),
FUint32: proto.Uint32(1030),
Expand All @@ -642,12 +643,12 @@ func TestMessageGogo(t *testing.T) {
FString: proto.String("map_submsg val"),
},
},
FNestedSubmsg: &pb.MessageGogo_NestedMessage{
FNestedSubmsg: &pb_gogo.MessageGogo_NestedMessage{
FString: proto.String("nested_submsg val"),
},
FToplevelEnum: pb.ToplevelEnumV2_TOPLEVEL_ENUM_V2_B.Enum(),
FNestedEnum: pb.MessageGogo_NESTED_ENUM_B.Enum(),
FOneof: &pb.MessageGogo_FOneofA{"string in oneof"},
FNestedEnum: pb_gogo.MessageGogo_NESTED_ENUM_B.Enum(),
FOneof: &pb_gogo.MessageGogo_FOneofA{"string in oneof"},
FBytes: []byte("also some string"),
FDuration: time.Second,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/go/skycfg/skycfg_test.go
Expand Up @@ -28,7 +28,7 @@ import (
"go.starlark.net/starlark"

"github.com/stripe/skycfg"
pb "github.com/stripe/skycfg/test_proto"
pb "github.com/stripe/skycfg/internal/testdata/test_proto"
)

var testFiles = map[string]string{
Expand Down
1 change: 1 addition & 0 deletions internal/testdata/test_proto/package.go
@@ -0,0 +1 @@
package test_proto
Expand Up @@ -16,7 +16,7 @@

syntax = "proto2";

option go_package = "github.com/stripe/skycfg/test_proto";
option go_package = "github.com/stripe/skycfg/internal/testdata/test_proto";
package skycfg.test_proto;

message MessageV2 {
Expand Down
Expand Up @@ -16,7 +16,7 @@

syntax = "proto3";

option go_package = "github.com/stripe/skycfg/test_proto";
option go_package = "github.com/stripe/skycfg/internal/testdata/test_proto";
package skycfg.test_proto;

import "google/protobuf/wrappers.proto";
Expand Down
1 change: 1 addition & 0 deletions internal/testdata/test_proto_gogo/package.go
@@ -0,0 +1 @@
package test_proto_gogo
Expand Up @@ -18,11 +18,11 @@ syntax = "proto2";

package skycfg.test_proto;

import "gogo.proto";
import "test_proto_v2.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "github.com/stripe/skycfg/internal/testdata/test_proto/test_proto_v2.proto";
import "google/protobuf/duration.proto";

option go_package = "github.com/stripe/skycfg/test_proto";
option go_package = "github.com/stripe/skycfg/internal/testdata/test_proto_gogo";

message MessageGogo {
option (gogoproto.sizer) = false;
Expand Down
136 changes: 0 additions & 136 deletions testdata/gogo.proto

This file was deleted.

0 comments on commit 40659e5

Please sign in to comment.