pkgsite: golang.org/x/pkgsite/internal/testing/sample Index | Files

package sample

import "golang.org/x/pkgsite/internal/testing/sample"

Package sample provides functionality for generating sample values of the types contained in the internal package.

Index

Package Files

documentation.gen.go sample.go

Variables

var (
    DocumentationHTML = testconversions.MakeHTMLForTest("" /* 11431 byte string literal not displayed */,
    )
    DocumentationSource = []byte{ /* 7691 elements not displayed */ }
    Documentation       = &internal.Documentation{
        Synopsis: Synopsis,
        GOOS:     GOOS,
        GOARCH:   GOARCH,
        HTML:     DocumentationHTML,
        Source:   DocumentationSource,
    }
)
var (
    ModulePath      = "github.com/valid/module_name"
    RepositoryURL   = "https://github.com/valid/module_name"
    VersionString   = "v1.0.0"
    CommitTime      = NowTruncated()
    LicenseType     = "MIT"
    LicenseFilePath = "LICENSE"
    LicenseMetadata = []*licenses.Metadata{
        {
            Types:    []string{LicenseType},
            FilePath: LicenseFilePath,
            Coverage: licensecheck.Coverage{
                Percent: 100,
                Match:   []licensecheck.Match{{Name: LicenseType, Type: licensecheck.MIT, Percent: 100}},
            },
        },
    }
    Licenses = []*licenses.License{
        {Metadata: LicenseMetadata[0], Contents: []byte(`Lorem Ipsum`)},
    }
    NonRedistributableLicense = &licenses.License{
        Metadata: &licenses.Metadata{
            FilePath: "NONREDIST_LICENSE",
            Types:    []string{"UNKNOWN"},
        },
        Contents: []byte(`unknown`),
    }
    PackageName    = "foo"
    Suffix         = "foo"
    PackagePath    = path.Join(ModulePath, Suffix)
    V1Path         = PackagePath
    Imports        = []string{"path/to/bar", "fmt"}
    Synopsis       = "This is a package synopsis"
    ReadmeFilePath = "README.md"
    ReadmeContents = "readme"
    GOOS           = "linux"
    GOARCH         = "amd64"
)

These sample values can be used to construct test cases.

var LicenseCmpOpts = []cmp.Option{
    cmp.Comparer(coveragePercentEqual),
    cmpopts.IgnoreFields(licensecheck.Match{}, "Start", "End"),
}

LicenseCmpOpts are options to use when comparing licenses with the cmp package.

func AddLicense Uses

func AddLicense(m *internal.Module, lic *licenses.License)

func AddPackage Uses

func AddPackage(m *internal.Module, pkg *internal.Unit) *internal.Module

func AddUnit Uses

func AddUnit(m *internal.Module, u *internal.Unit)

func DefaultModule Uses

func DefaultModule() *internal.Module

func DefaultVersionMap Uses

func DefaultVersionMap() *internal.VersionMap

func Module Uses

func Module(modulePath, version string, suffixes ...string) *internal.Module

Module creates a Module with the given path and version. The list of suffixes is used to create Units within the module.

func ModuleInfo Uses

func ModuleInfo(modulePath, versionString string) *internal.ModuleInfo

func NowTruncated Uses

func NowTruncated() time.Time

NowTruncated returns time.Now() truncated to Microsecond precision.

This makes it easier to work with timestamps in PostgreSQL, which have Microsecond precision:

https://www.postgresql.org/docs/9.1/datatype-datetime.html

func PackageMeta Uses

func PackageMeta(fullPath string) *internal.PackageMeta

func UnitEmpty Uses

func UnitEmpty(path, modulePath, version string) *internal.Unit

func UnitForModuleRoot Uses

func UnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit

func UnitForPackage Uses

func UnitForPackage(path, modulePath, version, name string, isRedistributable bool) *internal.Unit

UnitForPackage constructs a unit with the given module path and suffix.

If modulePath is the standard library, the package path is the suffix, which must not be empty. Otherwise, the package path is the concatenation of modulePath and suffix.

The package name is last component of the package path.

func UnitMeta Uses

func UnitMeta(path, modulePath, version, name string, isRedistributable bool) *internal.UnitMeta

Package sample imports 14 packages (graph) and is imported by 2 packages. Updated 2020-10-28. Refresh now. Tools for package owners.