aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/path_test.go
AgeCommit message (Collapse)Author
2026-03-26all: fix rangeintHana Kim
Change-Id: I58ed5e7d2a3bbc13bc389ac7239737e18856dbfe Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753427 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-17all: fix minmaxHana Kim
Change-Id: I1eacfe303e724fc4dfe371b10a3762627162285d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753425 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com>
2021-05-06internal/{postgres,frontend}: group search resultsJonathan Amsterdam
Group search results by module. Show the highest-ranking package of each module, and display the other packages as sub-results, in the same snippet as the winning package but smaller. Also, display packages from later major module versions before earlier ones, even if they have a lower score. All this is protected by an experiment. Change-Id: Iabc7fcf4e916289617b6c1c755904a27163ad554 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/316471 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-04-08internal/postgres,etc: finish MustInsertModule cleanupJonathan Amsterdam
Now that there are no callers of MustInsertModule, rename MustInsertModuleLatest to MustInsertModule. We can also remove MustInsertModuleLMV. Change-Id: Ieb554ee32696c168be4cc0a14ecece9f4c6b91b4 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308271 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-07internal/postgres: use MustInsertModuleLatestJonathan Amsterdam
For most internal/postgres tests, update latest-version information when we insert a module. That is more like what actually happens on the worker, and some features now rely on it, so we should do it everywhere. Some tests still use a custom go.mod file, so we can't switch to MustInsertModuleLatest for those, because it uses a minimal go.mod file. Change-Id: Ie5030aee4ed9c837931fddb8757e37bf6373a8c7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/307871 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-04-06internal/postgres: fix GetLatestMajorPathForV1Path for gopkg.inJonathan Amsterdam
GetLatestMajorPathForV1Path was not handling the special case of gopkg.in modules correctly. Also, split the logic for extracting the major version of a module path to a separate function. Change-Id: Ie7758330a14ebaab6360fafcc4bf2d3ae46f6479 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/307470 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2021-04-06internal/postgres: clarify TestGetLatestMajorPathForV1PathJonathan Amsterdam
I found this test hard to understand because it was doing so much to the test inputs. I brought the test inputs and expected values closer to the actual arguments and return values of the function under test. Change-Id: I6d72033e21eddfcc78f5803563c4bbf9e2e19356 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/307392 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-26internal/postgres: test upsertPaths concurrentlyJonathan Amsterdam
Add a test that looks for problems executing upsertPaths concurrently. Change-Id: Ifb18f81b937ad115a248ef57cd76c86bb1e5ac40 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296552 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-26internal/postgres: refactor path insertionJonathan Amsterdam
Move the module-independent part of insertPaths to a separate function, upsertPaths, and put it in the paths.go file so it is near it's single-path cousin. Write a simple test for it. Change-Id: I3f4a6d3e21836b2840153354c880f8be823b466b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296551 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-26internal/postgres: rewrite upsertPath and test concurrencyJonathan Amsterdam
Originally upsertPath selected a path first, then inserted it if it wasn't present. This led to uniqueness constraint violations even with fully serializable transactions (see https://www.postgresql.org/message-id/CAOqyxwL4E_JmUScYrnwd0_sOtm3bt4c7G%2B%2BUiD2PnmdGJFiqyQ%40mail.gmail.com). If the upsert is done first and then the select, then everything works fine, as the test verifies. Change-Id: I182458b6a7cc788a4adc4e72c90ef605c035e9ed Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296550 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-12internal/postgres: parallelize testsJonathan Amsterdam
Run tests in parallel on separate databases. With four DBs, the time to run all the package's tests is cut in about half, from 50s to 25s (the time varies from run to run). Instead of a global variable holding a single DB, we set up a channel populated with DBs. Each test receives from the channel to get a DB to use, and sends it to the channel when done. Because a test may have to wait to get a DB, we can't set an individual timeout for some tests because acquiring the DB can take some time. Individual test timeouts aren't really important, because `go test` will time out the entire run after 10 minutes anyway. The only test that can't be run in parallel is TestSearch, because it reads metrics before and after each sub-test to compute a delta, thereby implicitly assuming that no other Search calls are running in parallel. Change-Id: Icb35dbd2f146e27d82d4eef81343cf9725252155 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291449 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-11internal/postgres: add MustInsertModule for testingJonathan Amsterdam
Simplifies frequent calls to InsertModule. Change-Id: Iafcf5ec8d71eb9ab541ceecb2d85eb0d9b5119b1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291269 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-09internal/postgres: read and write deprecated commentJonathan Amsterdam
Insert the deprecated comment into the modules table, and read it back out. For golang/go#41321 Change-Id: Ib4f2c8ceb70e28940b18f52d25b2a0d05c57648d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290098 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-01-19internal: delete experiment not-at-v1Julie Qiu
Additionally, only redirect if the non-v1 path does not match the full path, and is actually a non-v1 path. Otherwise, this will redirect requests to <path>@<missing-version> to <path>@latest, or <path>/v3 to <path>, instead of return a 404 that allows the user to fetch the missing version. Change-Id: I66946062d341477fdc19bfc2a0f18b848943807d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/284580 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-01-12internal/postgres: GetLatestMajorPathForV1PathJulie Qiu
GetLatestMajorPathForV1Path returns the path that is the latest major for the v1path. Change-Id: Iec02b0771427b535817b5bd3794f6aa1a807280d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/282617 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-01-11internal/postgres: move code from path_test.go to unit_test.goJulie Qiu
Pure code in motion. Change-Id: Ib2615e00f27a358de2321314c19001f21c11f648 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/282619 Reviewed-by: Jonathan Amsterdam <jba@google.com> Trust: Julie Qiu <julie@golang.org>
2021-01-05internal/postgres: remove get-unit-meta-query experimentJulie Qiu
Change-Id: Iebd900374295793727e3ac8f17c883bfc3847861 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280161 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-12-16internal/postgres: fix GetUnitMeta with experiment flagJulie Qiu
getUnitMetaQuery was missing "m.has_go_mod" in the SELECT, due to a merge conflict. Tests are updated to catch errors with and without the experiment flag for the future. Change-Id: I4c8f5db7fb014bd81ff379e3cd93b65831958fd0 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/278753 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-12-14internal/postgres: prefer longest module pathJulie Qiu
The go command determines the latest minor version by picking the longest module path that exists, then the latest version of that. For example, given two "latest" possibilities for cloud.google.com/go/pubsublite: - cloud.google.com/go@v0.69.0/pubsublite - cloud.google.com/go/pubsublite@v0.4.0 "go get cloud.google.com/go/pubsublite" will choose cloud.google.com/go/pubsublite@v0.4.0. Previously, pkg.go.dev/cloud.google.com/pubsublite would show cloud.google.com/go@v0.69.0/pubsublite. This change updates the site to display cloud.google.com/go/pubsublite@v0.4.0. Note that given these two "latest" possibilities: - cloud.google.com/go@v0.74.0/compute/metadata - cloud.google.com/go/compute/metadata@v0.0.0-20181115181204-d50f0e9b2506 "go get cloud.google.com/go/compute/metadata" will return cloud.google.com/go@v0.74.0/compute/metadata. The reason is because "go get cloud.google.com/go/compute/metadata" will look for tagged versions of the module cloud.google.com/go/compute/metadata. Not finding any, it will look for the pseudo-version for the current tip of the default branch. Since today, there's no go.mod there, it proceeds as if this subdirectory was never a nested module. It will then try "cloud.google.com/go/compute" and so on until it eventually finds that cloud.google.com/go@v0.74.0/compute/metadata has this package. Pkg.go.dev/cloud.google.com/go/compute/metadata already shows cloud.google.com/go@v0.74.0/compute/metadata. A test is added to verify this logic. Fixes golang/go#43166 Change-Id: I748fd2693ad7be761e49df9da285902c6dd9101d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277512 Run-TryBot: Julie Qiu <julie@golang.org> Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-12-14internal/postgres: move TestGetStdlib to stdlib_test.goJulie Qiu
Change-Id: I59b91e8785dfb0d0657b6285175c447b0ccdd119 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277652 Run-TryBot: Julie Qiu <julie@golang.org> Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2020-12-14internal: add fields to unit meta structJamal Carvalho
Adds HasGoMod and VersionType fields to the UnitMeta struct and ModFileURL and IsStableVersion to UnitMain to support the details section in the right sidebar. For golang/go#43129 Change-Id: Id605d27d6a421d7c5ff2afc39f4532b11e49ace6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277832 Reviewed-by: Julie Qiu <julie@golang.org> Trust: Julie Qiu <julie@golang.org> Trust: Jamal Carvalho <jamal@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-12-02internal: add support for path@mainJulie Qiu
Support requests for path@main in addition to path@master. For golang/go#41312 Change-Id: Ie7665fbb3906e366c784a9cc592ffe37ef347671 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/274244 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-10-26internal/testing/sample: rename LegacyModule to ModuleJulie Qiu
For golang/go#39629 Change-Id: I83c2afdf32b58594e9ab00b545ae1bfebbd5491b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265005 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-10-20x/pkgsite: mark unit meta as redistributable in license bypass modeSean Hildebrand
Without this, the frontend is unable to display doc contents for non-redistributable packages even when in license bypass mode. Change-Id: I8e83929934bbdf5a6d1ec0adb556e901bdfee473 GitHub-Last-Rev: 4722ee39cb954f34cec0dff820ba3dae7a52f42f GitHub-Pull-Request: golang/pkgsite#11 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/263419 Trust: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2020-10-16internal/postgres: replace LegacyPackage in TestGetUnitMetaJulie Qiu
For golang/go#39629 Change-Id: Icb761e01ff50982a6b29e183f2782a0ba8bd3c0b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/262759 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-10-16internal/postgres: replace LegacyPackage in TestGetStdlibPathsJulie Qiu
For golang/go#39629 Change-Id: Ifb6e409239decc7df7282835c9c171d033be9d33 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/262760 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-10-02internal: deprecate LegacyModuleInfoJulie Qiu
For golang/go#39629 Change-Id: I157a325cfb4be06d77860ef5eb77b7bdb15a532a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258800 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-10-01internal/testing/sample: prefix legacy functions with LegacyJulie Qiu
For golang/go#39629 Change-Id: I3953c39e419ac8b74ac7f61ac6ffa9ec39e288aa Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258599 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-02internal: remove Unit.PackageJulie Qiu
Unit.Pacakge is removed, since it isn't need for anything. For golang/go#39629 Change-Id: Ic620603550874de8a0b4c37c67a88bee65ec7933 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/252323 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-02internal: move Unit.Package.Documentation to Unit.DocumentationJulie Qiu
The Documentation field is moved from Unit.Package.Documentation to Unit.Documentation. Unit.Package will be deprecated in a later CL. For golang/go#39629 Change-Id: Idc6d6598a2647a55b55c947120c322fec5da59cc Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/252321 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-01internal: rename PathInfo to UnitMetaJulie Qiu
PathInfo is renamed to UnitMeta, and GetPathInfo is renamed to GetUnitMeta. For golang/go#39629 Change-Id: Ia91cf7d2752988653efcc0e46a4d6b8b63017ef3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251978 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-01internal: replace Unit.DirectoryMeta with Unit.PathInfoJulie Qiu
Unit.DirectoryMeta is replaced with Unit.PathInfo DirectoryMeta isn't necessary and will be deleted in a future CL. For golang/go#39629 Change-Id: I521a062207d3f48592d6e949306a015458d1398d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251957 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-01internal/postgres: add data to PathInfoJulie Qiu
The following fields are added to GetPathInfo: - CommitTime - License metadata - RepositoryURL - PackageSourceURL For golang/go#39629 Change-Id: I664a0e96647ae2ad2404631e27f714b64db5c79c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251919 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-31internal: remove VersionType from ModuleInfoJulie Qiu
ModuleInfo.VersionType isn't being used, except to insert the field in InsertModule. The version type is now calculated in that function and removed from ModuleInfo. For golang/go#39629 Change-Id: I42e13bcfe9540a1b11babea8444cd053fc4db0c6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251698 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-28internal: update GetPathInfo to return PathInfoJulie Qiu
For golang/go#39629 Change-Id: Iedefbc03b24c6ce2c1b99e3148c0f757a726b687 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251162 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-28internal/testing/sample: change Directory to UnitJulie Qiu
For golang/go#39629 Change-Id: I45c040b27956be67fa1337c26dfa0c2a7ed5ddf3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251260 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-28internal: rename Directory to UnitJulie Qiu
For golang/go#39629 Change-Id: I7abe21764a58b6295926c6cd56ab327824570e77 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251163 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-25internal: rename VersionedDirectory to DirectoryJulie Qiu
For golang/go#39629 Change-Id: I17171838c864c1708eab527caa2288c57b6b4def Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250506 Reviewed-by: Jamal Carvalho <jamal@golang.org>
2020-08-25internal: merge Directory and VersionedDirectoryJulie Qiu
Directory and VersionedDirectory are merged into a single struct, since VersionedDirectory doesn't provide additional value. In this CL, Directory is removed. VersionedDirectory will be renamed to Directory in the next CL to make it easier to review. For golang/go#39629 Change-Id: I4f29bcd5db673c1c715cdd0bc8bd5391cd65d45d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250505 Reviewed-by: Jamal Carvalho <jamal@golang.org>
2020-08-19internal/postgres: update GetPathInfo to prefer non-incompatible modulesMiguel Acero
Updates GetPathInfo to use orderByLatest in the query to prefer compatible modules. Updates golang/go#37714 Change-Id: I89fd654c414f860a2f8a327ff9a8fde07fd35120 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/249119 Run-TryBot: Miguel Acero <acero@google.com> Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-07-10internal: remove New suffix from structsJulie Qiu
The New suffix is removed from PackageNew and DirectoryNew, since the legacy methods are already prefixed with "Legacy". For golang/go#39629 Change-Id: I8be32310c6b451035021663000aac6ca845ee6e0 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241900 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-07internal: delete insert-directories experimentJulie Qiu
The insert-directories experiment flag is deleted, since we have already inserted data for all modules into the paths, package_imports, documentation, and readmes table, and been running that code path for a while. Updates golang/go#39629 Change-Id: I323850a462672c41ad0c67b6ab2b173bb32bf441 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241320 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-06internal/experiment: improve ergonomics for NewSet and NewContextJulie Qiu
Previously, NewSet and NewContext required the caller to construct a set that was passed in. The functions now accept experiment names, to make them easier to use. Change-Id: Id306902910d51483c48a6a3bc8205cf484694d6a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240857 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-01internal/postgres: support requests for master version in GetPathInfoJulie Qiu
At the moment, GetPathInfo only supports requests for the latest version or semantic versions. GetPathInfo is updated to support requests for the master version of a path, by joining with version_map for these requests. Updates golang/go#36811 Change-Id: I05f5df5df9cf95253b137827065ee56e6830cbc2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240613 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-16internal: add DirectoryMetaJulie Qiu
DirectoryMeta is added, which contains metadata for a directory. This struct will be used to return the list of directories in a given path in a follow up CL. Change-Id: I89880bd8104791510bc07c1fb3532f6a71bed24c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238245 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-11internal: add ModuleInfoJulie Qiu
ModuleInfo is added, which represents the module info for the new data model. ModuleInfo is embedded in LegacyModuleInfo. In order to support the existing overview tab functionality, GetDirectoryNew was changed to return the module README, regardless of whether there is a README for the directory. We will change this logic to display the README for the directory in a future CL. Change-Id: I624a6d99b711870826fd7dff9100d4ad47852db2 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/766801 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-10internal/testing/sample: add AddDirectory functionJonathan Amsterdam
Add a function that checks for duplicate directory paths. Change-Id: I4b8d10c4f4cb6cf88455bae73eb43ca706aee425 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/766368 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-09internal: rename ModuleInfo to LegacyModuleInfoJulie Qiu
ModuleInfo is renamed to LegacyModuleInfo, as a step towards deprecating LegacyReadmeFilePath and LegacyReadmeContents. In a follow up CL, we will add ModuleInfo as an embedded struct to LegacyModuleInfo. Change-Id: Ie452420448eec1d13edaf62e548df0b9e2cbbe4b Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/766479 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-08internal: prefix legacy structs with LegacyJulie Qiu
The following structs have been renamed with a Legacy prefix: * internal.Directory * internal.Package * internal.VersionedPackage * sample.Package The following fields on internal.ModuleInfo have also been changed: * ReadmeFilePath * ReadmeFileContents This is done to help us distinguish between legacy and method structs/methods while migrating code to the new data model. Change-Id: Ibedf71d4db6323ef5aa05d73a0240537ea6073d3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/765160 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-18internal/postgres: add a method for stdlib shortcutsJonathan Amsterdam
Add GetStdlibPaths, which finds all paths in the standard library that end in a given suffix. The goal is to redirect stdlib paths like, e.g. "http" to "net/http". Updates b/149933479. Change-Id: Ib79d55ebb52f1203d8e68f52f6ed8c05db786dfa Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747784 Reviewed-by: Julie Qiu <julieqiu@google.com>