From 53551586a010c34083412a91f1cec71dd298ebc4 Mon Sep 17 00:00:00 2001 From: pytimer Date: Tue, 26 Apr 2022 15:22:08 +0800 Subject: [PATCH] Add packages testing --- packages_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages_test.go b/packages_test.go index 9163aa0a0..d74ba4d3a 100644 --- a/packages_test.go +++ b/packages_test.go @@ -4,6 +4,7 @@ import ( "go/ast" "go/token" "path/filepath" + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -151,6 +152,20 @@ func TestPackage_rangeFiles(t *testing.T) { Path: "testdata/simple/api/api.go", PackagePath: "api", }, + { + Name: &ast.Ident{Name: "foo.go"}, + }: { + File: &ast.File{Name: &ast.Ident{Name: "foo.go"}}, + Path: "vendor/foo/foo.go", + PackagePath: "vendor/foo", + }, + { + Name: &ast.Ident{Name: "bar.go"}, + }: { + File: &ast.File{Name: &ast.Ident{Name: "bar.go"}}, + Path: filepath.Join(runtime.GOROOT(), "bar.go"), + PackagePath: "bar", + }, } var sorted []string