Skip to content

Commit

Permalink
Add test with explicit and implicit importpath
Browse files Browse the repository at this point in the history
  • Loading branch information
mering committed Sep 25, 2023
1 parent 5e644e2 commit 9f143bb
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/core/go_proto_library_importpath/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

# Common rules
proto_library(
name = "foo_proto",
srcs = ["foo.proto"],
)

go_proto_library(
name = "foo_go_proto",
importpath = "path/to/foo_go",
proto = ":foo_proto",
)

proto_library(
name = "bar_proto",
srcs = ["bar.proto"],
deps = [":foo_proto"],
)

go_proto_library(
name = "bar_go_proto",
proto = ":bar_proto",
deps = [":foo_go_proto"],
)

go_test(
name = "importpath_test",
srcs = ["importpath_test.go"],
deps = [
":bar_go_proto",
":foo_go_proto",
],
)
9 changes: 9 additions & 0 deletions tests/core/go_proto_library_importpath/bar.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

package tests.core.go_proto_library_importpath.bar;

import "tests/core/go_proto_library_importpath/foo.proto";

message Bar {
foo.Foo value = 1;
}
7 changes: 7 additions & 0 deletions tests/core/go_proto_library_importpath/foo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

package tests.core.go_proto_library_importpath.foo;

message Foo {
int64 value = 1;
}
22 changes: 22 additions & 0 deletions tests/core/go_proto_library_importpath/importpath_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package importpath_test

import (
"fmt"
"testing"

bar_proto "tests/core/go_proto_library_importpath/bar_go_proto"
foo_proto "path/to/foo_go"
)

func Test(t *testing.T) {
bar := &bar_proto.Bar{}
bar.Value = &foo_proto.Foo{}
bar.Value.Value = 5

var expected int64 = 5
if bar.Value.Value != expected {
t.Errorf(fmt.Sprintf("Not equal: \n"+
"expected: %s\n"+
"actual : %s", expected, bar.Value.Value))
}
}

0 comments on commit 9f143bb

Please sign in to comment.