thirdparty

package
v0.0.0-...-81a76c0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 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

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

StoreSuite writes a test suite in JSON format.

func StoreSuiteFile

func StoreSuiteFile(filename string, s *Suite) error

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

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

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. All file path references will
	// be relative to this directory. If empty the root of the repository is
	// used.
	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"`

	// 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

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

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

func (p *Package) Validate() error

Validate package definition.

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

func (p *Project) ID() string

ID returns an identifier for the project.

func (*Project) Reason

func (p *Project) Reason() string

Reason returns the reason why the test is skipped.

func (*Project) Skip

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

func (p *Project) Validate() error

Validate project definition.

type Projects

type Projects []*Project

Projects is a collection of third-party integration tests.

func (Projects) Ranked

func (p Projects) Ranked() Projects

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

func (Projects) Tests

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

Tests returns all test cases for the projects collection.

func (Projects) Top

func (p Projects) Top(n int) Projects

Top returns the top n most popular projects.

func (Projects) Validate

func (p Projects) Validate() error

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

func (s *Step) Validate() error

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

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

LoadSuite loads a test suite from JSON format.

func LoadSuiteFile

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

LoadSuiteFile loads a test suite from a JSON file.

func (*Suite) Validate

func (s *Suite) Validate() error

Validate the test suite.

type Test

type Test struct {
	Project *Project
	Package *Package
}

Test case for a given package within a project.

func (*Test) ID

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