aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/unit_test.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2020-10-24 11:30:13 -0400
committerJonathan Amsterdam <jba@google.com>2020-10-26 13:53:34 +0000
commit4bf4c1e8b614f14914c0f20a5aeed9c6e3afba45 (patch)
treecf933838e5ab2bae4306fb6b65ce42ee28e1ff27 /internal/postgres/unit_test.go
parent244535af9dc4b75ff3d387c93e35c60467cbf85e (diff)
downloadgo-x-pkgsite-4bf4c1e8b614f14914c0f20a5aeed9c6e3afba45.tar.xz
internal/{frontend,postgres,testing}: set unit.NumImports
Set the NumImports field whenever we set Imports. Fixes b/171487247 Change-Id: I144fc2c36503c204712c694e0ff8a6ea4ece4bfb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/264860 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/postgres/unit_test.go')
-rw-r--r--internal/postgres/unit_test.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go
index 446c92c2..53603643 100644
--- a/internal/postgres/unit_test.go
+++ b/internal/postgres/unit_test.go
@@ -223,6 +223,7 @@ func TestGetUnitFieldSet(t *testing.T) {
}
if fields&internal.WithImports != 0 {
u.Imports = sample.Imports
+ u.NumImports = len(sample.Imports)
}
if fields&internal.WithLicenses == 0 {
u.LicenseContents = nil
@@ -302,6 +303,7 @@ func unit(fullPath, modulePath, version, name string, readme *internal.Readme, s
u.Subdirectories = subdirectories(modulePath, suffixes)
if u.IsPackage() {
u.Imports = sample.Imports
+ u.NumImports = len(sample.Imports)
u.Documentation = sample.Documentation
}
return u