Skip to content

Commit 361d6b0

Browse files
authored
Restructure test proto files (#5)
1 parent 08f1904 commit 361d6b0

File tree

4 files changed

+72
-68
lines changed

4 files changed

+72
-68
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ Assume you have the following `.proto` file defining `Foo` and `Qux` messages:
4141
```protobuf
4242
syntax = "proto3";
4343
44-
package test;
44+
package api.v1;
45+
option go_package = "github.com/afritzler/protoequal/test/api/v1";
4546
47+
// The Foo message with Bar, Baz fields and a nested message Qux.
4648
message Foo {
47-
string bar = 1;
48-
string baz = 2;
49-
Qux qux = 3;
49+
string bar = 1; // Bar field
50+
string baz = 2; // Baz field
51+
Qux qux = 3; // Qux is a nested message
5052
}
5153
54+
// The Qux message with Driver and Handle fields.
5255
message Qux {
53-
string driver = 1;
54-
string handle = 2;
56+
string driver = 1; // Driver field
57+
string handle = 2; // Handle field
5558
}
5659
```
5760

@@ -69,7 +72,7 @@ import (
6972

7073
"google.golang.org/protobuf/proto"
7174
. "github.com/afritzler/protoequal"
72-
"github.com/afritzler/protoequal/test"
75+
"github.com/afritzler/protoequal/test/api/v1"
7376
"github.com/onsi/gomega"
7477
)
7578

matchers_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package matchers_test
33
import (
44
"testing"
55

6+
v1 "github.com/afritzler/protoequal/test/api/v1"
67
"github.com/onsi/gomega"
78
"google.golang.org/protobuf/proto"
89

910
matchers "github.com/afritzler/protoequal"
10-
"github.com/afritzler/protoequal/test"
1111
)
1212

1313
func TestProtoEqualMatcher(t *testing.T) {
@@ -22,18 +22,18 @@ func TestProtoEqualMatcher(t *testing.T) {
2222
}{
2323
{
2424
name: "Should match identical messages",
25-
actual: &test.Foo{
25+
actual: &v1.Foo{
2626
Bar: "test-bar",
2727
Baz: "test-baz",
28-
Qux: &test.Qux{
28+
Qux: &v1.Qux{
2929
Driver: "foo-driver",
3030
Handle: "foo-handle",
3131
},
3232
},
33-
expected: &test.Foo{
33+
expected: &v1.Foo{
3434
Bar: "test-bar",
3535
Baz: "test-baz",
36-
Qux: &test.Qux{
36+
Qux: &v1.Qux{
3737
Driver: "foo-driver",
3838
Handle: "foo-handle",
3939
},
@@ -42,18 +42,18 @@ func TestProtoEqualMatcher(t *testing.T) {
4242
},
4343
{
4444
name: "Should not match different messages",
45-
actual: &test.Foo{
45+
actual: &v1.Foo{
4646
Bar: "test-bar",
4747
Baz: "test-baz",
48-
Qux: &test.Qux{
48+
Qux: &v1.Qux{
4949
Driver: "foo-driver",
5050
Handle: "foo-handle",
5151
},
5252
},
53-
expected: &test.Foo{
53+
expected: &v1.Foo{
5454
Bar: "different-bar",
5555
Baz: "test-baz",
56-
Qux: &test.Qux{
56+
Qux: &v1.Qux{
5757
Driver: "foo-driver",
5858
Handle: "foo-handle",
5959
},
@@ -62,18 +62,18 @@ func TestProtoEqualMatcher(t *testing.T) {
6262
},
6363
{
6464
name: "Should not match messages with different nested fields",
65-
actual: &test.Foo{
65+
actual: &v1.Foo{
6666
Bar: "test-bar",
6767
Baz: "test-baz",
68-
Qux: &test.Qux{
68+
Qux: &v1.Qux{
6969
Driver: "foo-driver",
7070
Handle: "foo-handle",
7171
},
7272
},
73-
expected: &test.Foo{
73+
expected: &v1.Foo{
7474
Bar: "test-bar",
7575
Baz: "test-baz",
76-
Qux: &test.Qux{
76+
Qux: &v1.Qux{
7777
Driver: "different-driver",
7878
Handle: "foo-handle",
7979
},

test/test.pb.go renamed to test/api/v1/test.pb.go

Lines changed: 47 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test.proto renamed to test/api/v1/test.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
syntax = "proto3";
22

3-
package test;
4-
option go_package = "github.com/afritzler/protoequal/test";
3+
package api.v1;
4+
option go_package = "github.com/afritzler/protoequal/test/api/v1";
55

66
// The Foo message with Bar, Baz fields and a nested message Qux.
77
message Foo {

0 commit comments

Comments
 (0)