package thirdparty
import "github.com/mmcloughlin/avo/tests/thirdparty"
Package thirdparty executes integration tests based on third-party projects that use avo.
Index ¶
- func StoreSuite(w io.Writer, s *Suite) error
- func StoreSuiteFile(filename string, s *Suite) error
- type Context
- type GithubRepository
- func (r GithubRepository) CloneURL() string
- func (r GithubRepository) String() string
- func (r GithubRepository) URL() string
- type Metadata
- type Package
- func (p *Package) IsRoot() bool
- func (p *Package) Name() string
- func (p *Package) Steps(c *Context) []*Step
- func (p *Package) Validate() error
- func (p *Package) WorkingDirectory() string
- type Project
- func (p *Project) ID() string
- func (p *Project) Reason() string
- func (p *Project) Skip() bool
- func (p *Project) Validate() error
- type Projects
- func (p Projects) Ranked() Projects
- func (p Projects) Tests() []*Test
- func (p Projects) Top(n int) Projects
- func (p Projects) Validate() error
- type Step
- type Suite
- func LoadSuite(r io.Reader) (*Suite, error)
- func LoadSuiteFile(filename string) (*Suite, error)
- func (s *Suite) Validate() error
- type Test
Functions ¶
func StoreSuite ¶
StoreSuite writes a test suite in JSON format.
func StoreSuiteFile ¶
StoreSuiteFile writes a test suite to a JSON file.
Types ¶
type Context ¶
type Context struct {
// Path to the avo version under test.
AvoDirectory string
// Path to the checked out third-party repository.
RepositoryDirectory string
}
Context specifies execution environment parameters for a third-party test.
type GithubRepository ¶
GithubRepository specifies a repository on github.
func (GithubRepository) CloneURL ¶
func (r GithubRepository) CloneURL() string
CloneURL returns the git clone URL.
func (GithubRepository) String ¶
func (r GithubRepository) String() string
func (GithubRepository) URL ¶
func (r GithubRepository) URL() string
URL returns the Github repository URL.
type Metadata ¶
type Metadata struct {
// Repository description.
Description string `json:"description,omitempty"`
// Homepage URL. Not the same as the Github page.
Homepage string `json:"homepage,omitempty"`
// Number of Github stars.
Stars int `json:"stars,omitempty"`
}
Metadata about the repository.
type Package ¶
type Package struct {
// Sub-package within the project under test. Used as the root directory for
// the test unless explicitly overridden.
SubPackage string `json:"pkg,omitempty"`
// Path to the module file for the avo generator package. This is necessary
// so the integration test can insert replace directives to point at the avo
// version under test.
Module string `json:"module"`
// Root directory for all steps in the test. All file path references will
// be relative to this directory. If empty, the sub-package directory is
// used, or otherwise the root of the repository.
Root string `json:"root,omitempty"`
// Setup steps. These run prior to the insertion of avo replace directives,
// therefore should be used if it's necessary to initialize new go modules
// within the repository.
Setup []*Step `json:"setup,omitempty"`
// Steps to run the avo code generator.
Generate []*Step `json:"generate"`
// Test steps. If empty, defaults to "go test ./...".
Test []*Step `json:"test,omitempty"`
}
Package defines an integration test for a package within a project.
func (*Package) IsRoot ¶
IsRoot reports whether the package is the root of the containing project.
func (*Package) Name ¶
Name of the package.
func (*Package) Steps ¶
Steps generates the list of steps required to execute the integration test for this package. Context specifies execution environment parameters.
func (*Package) Validate ¶
Validate package definition.
func (*Package) WorkingDirectory ¶
WorkingDirectory returns the base directory for all steps in the test.
type Project ¶
type Project struct {
// Repository for the project. At the moment, all projects are available on
// github.
Repository GithubRepository `json:"repository"`
// Repository metadata.
Metadata Metadata `json:"metadata"`
// Default git branch. This is used when testing against the latest version.
DefaultBranch string `json:"default_branch,omitempty"`
// Version as a git sha, tag or branch.
Version string `json:"version"`
// If the project test has a known problem, record it by setting this to a
// non-zero avo issue number. If set, the project will be skipped in
// testing.
KnownIssue int `json:"known_issue,omitempty"`
// Packages within the project to test.
Packages []*Package `json:"packages"`
}
Project defines an integration test based on a third-party project using avo.
func (*Project) ID ¶
ID returns an identifier for the project.
func (*Project) Reason ¶
Reason returns the reason why the test is skipped.
func (*Project) Skip ¶
Skip reports whether the project test should be skipped. If skipped, a known issue will be set.
func (*Project) Validate ¶
Validate project definition.
type Projects ¶
type Projects []*Project
Projects is a collection of third-party integration tests.
func (Projects) Ranked ¶
Ranked returns a copy of the projects list ranked in desending order of popularity.
func (Projects) Tests ¶
Tests returns all test cases for the projects collection.
func (Projects) Top ¶
Top returns the top n most popular projects.
func (Projects) Validate ¶
Validate the project collection.
type Step ¶
type Step struct {
Name string `json:"name,omitempty"`
WorkingDirectory string `json:"dir,omitempty"`
Commands []string `json:"commands"`
}
Step represents a set of commands to run as part of the testing plan for a third-party package.
func (*Step) Validate ¶
Validate step parameters.
type Suite ¶
type Suite struct {
// Projects to test.
Projects Projects `json:"projects"`
// Time of the last update to project metadata.
MetadataLastUpdate time.Time `json:"metadata_last_update"`
}
Suite defines a third-party test suite.
func LoadSuite ¶
LoadSuite loads a test suite from JSON format.
func LoadSuiteFile ¶
LoadSuiteFile loads a test suite from a JSON file.
func (*Suite) Validate ¶
Validate the test suite.
type Test ¶
Test case for a given package within a project.
func (*Test) ID ¶
ID returns an identifier for the test case.
Source Files ¶
- Version
- v0.6.0 (latest)
- Published
- Jan 7, 2024
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 8 months ago –
Tools for package owners.