From 39dacb72eecd5582e06e7edc1bb9a29b2afaefc7 Mon Sep 17 00:00:00 2001 From: Charles Lowell <10964656+chlowell@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:02:23 -0700 Subject: [PATCH] Test apiviewgo review names for v2 module (#8933) --- src/go/cmd/api_view_test.go | 9 +++++++++ src/go/cmd/pkg_test.go | 6 ++++++ src/go/cmd/testdata/test_major_version/go.mod | 3 +++ .../cmd/testdata/test_major_version/subpackage/test.go | 3 +++ 4 files changed, 21 insertions(+) create mode 100644 src/go/cmd/testdata/test_major_version/go.mod create mode 100644 src/go/cmd/testdata/test_major_version/subpackage/test.go diff --git a/src/go/cmd/api_view_test.go b/src/go/cmd/api_view_test.go index 8b5daf13d45..23a2fa00811 100644 --- a/src/go/cmd/api_view_test.go +++ b/src/go/cmd/api_view_test.go @@ -290,6 +290,15 @@ func TestAliasDiagnostics(t *testing.T) { } } +func TestMajorVersion(t *testing.T) { + review, err := createReview(filepath.Clean("testdata/test_major_version")) + require.NoError(t, err) + require.Equal(t, "Go", review.Language) + require.Equal(t, "test_major_version", review.Name) + require.Equal(t, 1, len(review.Navigation)) + require.Equal(t, "test_major_version/subpackage", review.Navigation[0].Text) +} + func TestVars(t *testing.T) { review, err := createReview(filepath.Clean("testdata/test_vars")) require.NoError(t, err) diff --git a/src/go/cmd/pkg_test.go b/src/go/cmd/pkg_test.go index 78816eb8149..4f98abb2ba5 100644 --- a/src/go/cmd/pkg_test.go +++ b/src/go/cmd/pkg_test.go @@ -14,6 +14,12 @@ func TestName(t *testing.T) { for _, test := range []struct { modulePath, moduleRoot, pkgPath, want string }{ + { + modulePath: "test_major_version/v2", + moduleRoot: "testdata/test_major_version", + pkgPath: "subpackage", + want: "test_major_version/subpackage", + }, { modulePath: "test_package_name", moduleRoot: "testdata/test_package_name/test_package_name@v1.0.0", diff --git a/src/go/cmd/testdata/test_major_version/go.mod b/src/go/cmd/testdata/test_major_version/go.mod new file mode 100644 index 00000000000..0ac575ee43a --- /dev/null +++ b/src/go/cmd/testdata/test_major_version/go.mod @@ -0,0 +1,3 @@ +module test_major_version/v2 + +go 1.18 diff --git a/src/go/cmd/testdata/test_major_version/subpackage/test.go b/src/go/cmd/testdata/test_major_version/subpackage/test.go new file mode 100644 index 00000000000..634ad31f5ed --- /dev/null +++ b/src/go/cmd/testdata/test_major_version/subpackage/test.go @@ -0,0 +1,3 @@ +package subpackage + +type S string