Skip to content

Commit

Permalink
Restructure test proto files
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed Oct 25, 2024
1 parent 08f1904 commit 08596ce
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 68 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ Assume you have the following `.proto` file defining `Foo` and `Qux` messages:
```protobuf
syntax = "proto3";
package test;
package api.v1;
option go_package = "github.com/afritzler/protoequal/test/api/v1";
// The Foo message with Bar, Baz fields and a nested message Qux.
message Foo {
string bar = 1;
string baz = 2;
Qux qux = 3;
string bar = 1; // Bar field
string baz = 2; // Baz field
Qux qux = 3; // Qux is a nested message
}
// The Qux message with Driver and Handle fields.
message Qux {
string driver = 1;
string handle = 2;
string driver = 1; // Driver field
string handle = 2; // Handle field
}
```

Expand All @@ -69,7 +72,7 @@ import (

"google.golang.org/protobuf/proto"
. "github.com/afritzler/protoequal"
"github.com/afritzler/protoequal/test"
"github.com/afritzler/protoequal/test/api/v1"
"github.com/onsi/gomega"
)

Expand Down
26 changes: 13 additions & 13 deletions matchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package matchers_test
import (
"testing"

v1 "github.com/afritzler/protoequal/test/api/v1"
"github.com/onsi/gomega"
"google.golang.org/protobuf/proto"

matchers "github.com/afritzler/protoequal"
"github.com/afritzler/protoequal/test"
)

func TestProtoEqualMatcher(t *testing.T) {
Expand All @@ -22,18 +22,18 @@ func TestProtoEqualMatcher(t *testing.T) {
}{
{
name: "Should match identical messages",
actual: &test.Foo{
actual: &v1.Foo{
Bar: "test-bar",
Baz: "test-baz",
Qux: &test.Qux{
Qux: &v1.Qux{
Driver: "foo-driver",
Handle: "foo-handle",
},
},
expected: &test.Foo{
expected: &v1.Foo{
Bar: "test-bar",
Baz: "test-baz",
Qux: &test.Qux{
Qux: &v1.Qux{
Driver: "foo-driver",
Handle: "foo-handle",
},
Expand All @@ -42,18 +42,18 @@ func TestProtoEqualMatcher(t *testing.T) {
},
{
name: "Should not match different messages",
actual: &test.Foo{
actual: &v1.Foo{
Bar: "test-bar",
Baz: "test-baz",
Qux: &test.Qux{
Qux: &v1.Qux{
Driver: "foo-driver",
Handle: "foo-handle",
},
},
expected: &test.Foo{
expected: &v1.Foo{
Bar: "different-bar",
Baz: "test-baz",
Qux: &test.Qux{
Qux: &v1.Qux{
Driver: "foo-driver",
Handle: "foo-handle",
},
Expand All @@ -62,18 +62,18 @@ func TestProtoEqualMatcher(t *testing.T) {
},
{
name: "Should not match messages with different nested fields",
actual: &test.Foo{
actual: &v1.Foo{
Bar: "test-bar",
Baz: "test-baz",
Qux: &test.Qux{
Qux: &v1.Qux{
Driver: "foo-driver",
Handle: "foo-handle",
},
},
expected: &test.Foo{
expected: &v1.Foo{
Bar: "test-bar",
Baz: "test-baz",
Qux: &test.Qux{
Qux: &v1.Qux{
Driver: "different-driver",
Handle: "foo-handle",
},
Expand Down
93 changes: 47 additions & 46 deletions test/test.pb.go → test/api/v1/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/test.proto → test/api/v1/test.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";

package test;
option go_package = "github.com/afritzler/protoequal/test";
package api.v1;
option go_package = "github.com/afritzler/protoequal/test/api/v1";

// The Foo message with Bar, Baz fields and a nested message Qux.
message Foo {
Expand Down

0 comments on commit 08596ce

Please sign in to comment.