aboutsummaryrefslogtreecommitdiff
path: root/internal/testing/sample/sample.go
AgeCommit message (Collapse)Author
2020-08-31internal: delete DirectoryMeta.V1PathJulie Qiu
DirectoryMeta.V1Path isn't used anywhere, so it is deleted and computed using internal.V1Path when needed For golang/go#39629 Change-Id: I6c69bf098ec0aff45b830a1400885b54d50937ef Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251580 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-31internal: change signature of V1PathJulie Qiu
V1Path is changed to accepted a fullPath and modulePath, which is more ergonomic than passing in a suffix. For golang/go#39629 Change-Id: Ic14262081bb3c0899c8901fd5e6a50b8da6014fc Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251579 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/testing/sample: add DocumentationJulie Qiu
For golang/go#39629 Change-Id: Ia7aab1f56d70f86e570a365a35391e1024d66d7b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251271 Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@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 Module.Directories to Module.UnitsJulie Qiu
For golang/go#39629 Change-Id: I52d071d035c66dd385e4d32c08b039fddfcb01d7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251173 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-28internal/postgres: add WithImports fieldset to GetDirectoryJulie Qiu
GetDirectory now supports the WithImports fieldset, which lets the caller fetch only the imports. The Package.Imports field is moved to Directory.Imports. For golang/go#39629. Change-Id: I5d597555fa372cc1ee70390460d349fa83f31425 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251272 Reviewed-by: Jamal Carvalho <jamal@golang.org>
2020-08-26internal: add Name to DirectoryMetaJulie Qiu
For golang/go#39629 Change-Id: Iad754b0c4e82b859b6a3dac60ace85c621423d7b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250538 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-26internal/testing/sample: fix sample DirectoryMetaJulie Qiu
Missing fields on sample.DirectoryMeta are added. For golang/go#39629 Change-Id: Iec69dea44fee12aa97eea9f8e1ba7d7cb3e2ada3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250547 Reviewed-by: Jonathan Amsterdam <jba@google.com> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-08-26internal: removed unused PackageMeta fieldsJulie Qiu
For golang/go#39629 Change-Id: I6e86c76db37f447a3cb46c33cc8ccee3dc93caf6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250545 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-25internal,internal/postgres: remove non-redist data on readJonathan Amsterdam
The postgres package removes non-redistributable data during insertion. Also remove it when reading, unless bypassLicenseCheck is true. Handling this in the DataSource layer simplifies frontend code, which can avoid redistributability checks and knowing about the bypass flag except when it constructs its DataSource. As part of this work, move the removal of non-redistributable data to the internal package, so it can eventually be used by the proxy data source. For golang/go#39602 Change-Id: Ia1362ead917b42f844b4c4d25ade74cdcb03d4dc Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250017 Reviewed-by: Julie Qiu <julie@golang.org>
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-06internal/postgres,etc.: support bypassing license restrictionsJonathan Amsterdam
Add a mode to postgres.DB where data is saved even if the module or package is not redistributable. This "bypassing license restrictions" mode is off by default. Add a flag to the worker binary to turn it on. Used a flag rather than an environment variable so there is no way for ambient state to affect the binary for this important decision. Also: - Add a test to verify that license data is removed/not removed depending on the bypass setting. - Fix a bug where the new model insertion wasn't omitting documentation for non-redistributable modules. - Fix a bug in internal/sample where the top-level readme wasn't getting populated. A later CL will change the frontend to bypass the check. For golang/go#39602 For golang/go#39629 Change-Id: I67a6d24c18f3b93cfbfc9ec2a20159c07a84e077 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/246957 Reviewed-by: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> 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-10internal/postgres: add GetPackagesInDirectoryJulie Qiu
GetPackagesInDirectory is added, which uses the paths table to get all of the packages within a given directory path. This will replace LegacyGetDirectory and LegacyGetPackagesInModule in creating the directories tab. For golang/go#39629 Change-Id: I4b39690e838756421bee9b5ca389081e184761bf Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241838 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-07internal: use safehtml for doc fieldsJonathan Amsterdam
Change the type of the documentation fields from string to safehtml.HTML. This forces the conversions between strings and safehtml.HTML values to happen at the lowest level, reading and writing to the database. That increases our confidence that nothing will modify the HTML after it is read from the DB and before it is used in a template. Change-Id: If5d65123ce2b69ef3183221048aa6d081b003762 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240510 Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-06internal/sample: use module path with valid GitHub URL patternJulie Qiu
GitHub paths typically have three components. Change our sample module path to match that URL pattern. Change-Id: I049df016b46affd942209a2aee798fdb5537e0a6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240943 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-29internal/postgres: remove module from version_map in DeleteModuleBharath Thiruveedula
postgres.DeleteModule is updated to delete the corresponding module_path and resolved_version row from the version_map table. Fixes #39633 Change-Id: I9de46b08e535bea52c2ea4dbab1c71a8e1c2c2f7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238637 Reviewed-by: Julie Qiu <julie@golang.org>
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-10internal/postgres: upsert module dataJonathan Amsterdam
When we insert module information, make sure we overwrite existing rows. Previously, we specified that new data should be ignored if the row already existed, which meant that we were adding rows but never changing them. That didn't matter at one point, when we deleted a module before re-inserting it, but we no longer delete, so we must upsert. We also fix a number of places where our test modules had duplicate directories. The upserts failed for these. Change-Id: I97465b11e4ea6cbb7835e883f36f098445207eba Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/766365 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/sample: fix SourceInfoJonathan Amsterdam
Construct the sample SourceInfo from the given module path, not the global one. Change-Id: I2d61d0b234c591a2a6fb03bfbf329549cc0df507 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750122 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-04internal/frontend: use GetPathInfoJonathan Amsterdam
Use GetPathInfo to determine how to serve a path. Protect behind an experiment. Change-Id: Ia78b0049e4d76216654216c66a6c0786f38bd8f5 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/731801 Reviewed-by: Julie Qiu <julieqiu@google.com> CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-05-04many: use the new sample APIJonathan Amsterdam
Replace many calls to sample.DefaultModule, and all calls to sample.DefaultPackage, with calls to the new Module and Package functions. Change-Id: I76921e14502585f8ca9a4dba5de01d7055522f3f Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/733604 Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-04internal/testing/sample: further API improvementsJonathan Amsterdam
- Redo the arguments to Package so it can derive the Name and V1Path fields from them. - Add a list of suffixes to the arguments of Module. Change-Id: I966197846b49befceb04779c9a04162957fbeb87 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/733603 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-01internal/testing/sample: improvementsJonathan Amsterdam
This is the first step towards making sample clearer and less error-prone. - Rename Module and Package to DefaultModule and DefaultPackage, so existing code continues to work. In later CLs, I'll replace most or all calls to these functions. - Define ModuleInfo, Module and Package to take as arguments the most common fields. The Module function does _not_ create a package; it returns a module with no packages. - Most important: define AddPackage, which adds a Package to a Module and correctly updates Module.Directories. - Remove VersionedPackage, since it's clearer to create one directly. - Update a couple of call sites, just to get tests to pass. More updates in a later CL. Change-Id: I46eb94ba897d4f122483b58435107b8782c6044f Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/733619 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-23all: rename module to golang.org/x/pkgsiteJulie Qiu
golang.org/x/discovery is renamed to golang.org/x/pkgsite. When the repository is open sourced, it will be hosted at go.googlesource.com/pkgsite. Change-Id: Ifc3b45b771a385b99179e785447f2a87afcacf87 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/724273 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-15internal/postgres: insert into paths, readmes, documentation, package_importsJulie Qiu
InsertVersion now populates the following tables: - paths - readmes - documentation - package_imports Change-Id: Ib02220101d148a261cf55bd564cb9f9a46e60544 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/704882 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06all: rename internal.Version to internal.ModuleJonathan Amsterdam
Rename the type, and any variable of that type. Rename most functions from *Version* to *Module*, where it made sense. No other changes. Updates b/150143758. Change-Id: I13079411376be0af7e53a577fc6ca1c92c38b6cd Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/677160 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-06all: rename VersionInfo to ModuleInfoJonathan Amsterdam
This CL is pure renaming: - internal.VersionInfo to internal.ModuleInfo - related variables from vi to mi Updates b/150143758. Change-Id: I5da63a07d6f9b731016ffe92e403e5f2d9aadab7 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/673875 Reviewed-by: Julie Qiu <julieqiu@google.com> CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-03-27internal/postgres: read the has_go_mod columnJonathan Amsterdam
Add VersionInfo.HasGoMod, and read it from the has_go_mod column. Updates b/148519337. Change-Id: Ibdab57821f90b845b1ff49ebd62353d16f27c7bd Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/650283 Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27many: compute redistributability in the etlJonathan Amsterdam
The etl determines whether modules and packages are redistributable, and saves that information to the database. The frontend just reads the fields from the DB. This CL replaces internal/license with internal/licenses throughout the etl and frontend. A subsequent CL will replace it throughout the repo, and remove the internal/license package. Change-Id: If137d7c5e7e2ae326c28d0b5df80ddbeca134313 Fixes b/147505176. Change-Id: I68a38baa7f55d36db9a63764571e610ca53064a6 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/641370 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/license,licenses: improve license comparisonJonathan Amsterdam
Improve license comparison for tests so small changes to percentages don't matter. Change-Id: Id5f1118f4f2d95c6851a021ca0478e493e8070dc Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/637105 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27go.mod: update licensecheckJonathan Amsterdam
Update licensecheck to the latest version, which ignores Copyright notices for improved matching. Change-Id: I34197dfc75df073cac45986dd206295d0b5ae221 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/632521 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal: change Package.DocumentationHTML to string typeJulie Qiu
Previously Package.DocumentationHTML was a type []byte. This is now changed to a type string, so that is matches its database type (which is TEXT). Updates b/144650806 Change-Id: I87784576e719d8aa666b0a21848a9ea6f10f8cf1 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/600048 Reviewed-by: Robert Findley <rfindley@google.com> CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-03-27internal: change License.Contents to string typeJulie Qiu
Previously license.License.Contents was a type []byte. This is now changed to a type string, so that is matches its database type (which is TEXT). Updates b/144650806 Change-Id: I4b7cb1c234ccea330d6f3ae7cf50a67ea6021693 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/600047 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27internal: change VersionInfo.ReadmeContents to string typeJulie Qiu
Previously VersionInfo.ReadmeContents was a type []byte. This is now changed to a type string, so that is matches its database type (which is TEXT). Updates b/144650806 Change-Id: I90e24dc8184b79a39f526e50ed1f75fd6d3895aa Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/600046 Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27internal/pagecheck: add checks for overview pagesJonathan Amsterdam
Change-Id: I643e59f9eb13f9b9abbf8c30daedb2264a3a65e3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/602822 Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27internal/license,internal/postgres: store license coverage in DBJonathan Amsterdam
Store the output of licensecheck.Cover in the licenses table. This will make our lives easier if we ever want to revisit our coverage parameters. In the process, generalize scanning of jsonb columns into Go values. Change-Id: Iadc89c89c2590e0894fefcdcd461283d90b2e701 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/601900 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal: add a testing directoryJonathan Amsterdam
Put all test-related packages there (sample, testhelper, integration). production risk: none Change-Id: I06673aaa5c3fd6966410f1c1ad2b34e4f2d88f94 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/599080 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>