internal/postgres: GetLatestMajorVersion returns module path if package is missing

Somehow the test for this was failing. It don't see how it ever could have worked,
but somehow it passed in CI.

Change-Id: Idc5f04a5d003c1abeffab0aac7eafab9bca77a7b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/276292
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/postgres/version.go b/internal/postgres/version.go
index a37425c..5d64996 100644
--- a/internal/postgres/version.go
+++ b/internal/postgres/version.go
@@ -128,9 +128,14 @@
 		return "", "", err
 	}
 	var latestModulePath, latestPackagePath string
-	row := db.db.QueryRow(ctx, q, args...)
-	if err := row.Scan(&latestModulePath, &latestPackagePath); err != nil {
+	if err := db.db.QueryRow(ctx, q, args...).Scan(&latestModulePath, &latestPackagePath); err != nil {
 		return "", "", err
 	}
+	// If the package path is not the one we're expecting, then it doesn't exist
+	// in the latest module version (or it would have been sorted first by the
+	// OrderByClause above).
+	if internal.V1Path(latestPackagePath, latestModulePath) != v1Path {
+		return latestModulePath, latestModulePath, nil
+	}
 	return latestModulePath, latestPackagePath, nil
 }