thirdparty

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package thirdparty executes integration tests based on third-party projects that use avo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StoreSuite added in v0.5.0

func StoreSuite(w io.Writer, s *Suite) error

StoreSuite writes a test suite in JSON format.

func StoreSuiteFile added in v0.5.0

func StoreSuiteFile(filename string, s *Suite) error

StoreSuiteFile writes a test suite to a JSON file.

Types

type Context added in v0.3.0

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 added in v0.3.0

type GithubRepository struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

GithubRepository specifies a repository on github.

func (GithubRepository) CloneURL added in v0.3.0

func (r GithubRepository) CloneURL() string

CloneURL returns the git clone URL.

func (GithubRepository) String added in v0.3.0

func (r GithubRepository) String() string

func (GithubRepository) URL added in v0.5.0

func (r GithubRepository) URL() string

URL returns the Github repository URL.

type Metadata added in v0.4.0

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 added in v0.5.0

func (p *Package) IsRoot() bool

IsRoot reports whether the package is the root of the containing project.

func (*Package) Name

func (p *Package) Name() string

Name of the package.

func (*Package) Steps added in v0.3.0

func (p *Package) Steps(c *Context) []*Step

Steps generates the list of steps required to execute the integration test for this package. Context specifies execution environment parameters.

func (*Package) Validate added in v0.3.0

func (p *Package) Validate() error

Validate package definition.

func (*Package) WorkingDirectory added in v0.6.0

func (p *Package) WorkingDirectory() string

WorkingDirectory returns the base directory for all steps in the test.

type Project added in v0.5.0

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 added in v0.5.0

func (p *Project) ID() string

ID returns an identifier for the project.

func (*Project) Reason added in v0.5.0

func (p *Project) Reason() string

Reason returns the reason why the test is skipped.

func (*Project) Skip added in v0.5.0

func (p *Project) Skip() bool

Skip reports whether the project test should be skipped. If skipped, a known issue will be set.

func (*Project) Validate added in v0.5.0

func (p *Project) Validate() error

Validate project definition.

type Projects added in v0.5.0

type Projects []*Project

Projects is a collection of third-party integration tests.

func (Projects) Ranked added in v0.5.0

func (p Projects) Ranked() Projects

Ranked returns a copy of the projects list ranked in desending order of popularity.

func (Projects) Tests added in v0.5.0

func (p Projects) Tests() []*Test

Tests returns all test cases for the projects collection.

func (Projects) Top added in v0.5.0

func (p Projects) Top(n int) Projects

Top returns the top n most popular projects.

func (Projects) Validate added in v0.5.0

func (p Projects) Validate() error

Validate the project collection.

type Step added in v0.3.0

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 added in v0.3.0

func (s *Step) Validate() error

Validate step parameters.

type Suite added in v0.5.0

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 added in v0.5.0

func LoadSuite(r io.Reader) (*Suite, error)

LoadSuite loads a test suite from JSON format.

func LoadSuiteFile added in v0.5.0

func LoadSuiteFile(filename string) (*Suite, error)

LoadSuiteFile loads a test suite from a JSON file.

func (*Suite) Validate added in v0.5.0

func (s *Suite) Validate() error

Validate the test suite.

type Test added in v0.5.0

type Test struct {
	Project *Project
	Package *Package
}

Test case for a given package within a project.

func (*Test) ID added in v0.5.0

func (t *Test) ID() string

ID returns an identifier for the test case.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL