fixtures

package module
v0.0.0-...-beb84ef Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: AGPL-3.0 Imports: 13 Imported by: 1

README

lookout-test-fixtures

To update the fixtures use the scraper utility. It will call the GitHub API to list the PRs defined in var fixtures in main.go. The output will be dumped as JSON files.

It is not required, but you may want to authenticate using these environment variables:

export GITHUB_USER=xxx
export GITHUB_TOKEN=yyy

The fixtures must be bundled using go-bindata.

go run cmd/scrape/main.go
go-bindata -modtime 1536310226 -pkg fixtures fixtures/

To store more than one fixture for a PR, for example to test incremental pushes to a branch, increment the Fixture.CurrentRevision number by one. The scraper utility will leave existing files, and create new ones with the -vN suffix.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NoopYes

func NoopYes() bool

NoopYes is a function that does absolutely nothing but returns true. I need to make this comment long enough so it would be catched by any linter that doesn't like long lines.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Fixture

type Fixture struct {
	Name string
	URL  PullRequestURL
	// There can be more than one revision of the fixture, but it should have
	// files for 0..CurrentRevision
	CurrentRevision int
}

Fixture is struct for a test case

func GetAll

func GetAll() []*Fixture

GetAll returns all fixtures

func GetByName

func GetByName(name string) *Fixture

GetByName returns fixture by name

func (Fixture) FilenameCC

func (f Fixture) FilenameCC(revision int) string

func (Fixture) FilenamePR

func (f Fixture) FilenamePR(revision int) string

func (Fixture) GetCommitRevision

func (f Fixture) GetCommitRevision() *pb.CommitRevision

GetCommitRevision builds a pb.CommitRevision from this fixture's GetPR()

func (Fixture) GetCommitsComparison

func (f Fixture) GetCommitsComparison() (*github.CommitsComparison, error)

GetCommitsComparison returns the fixture saved from the github.Client.Repositories.CompareCommits output

func (Fixture) GetPR

func (f Fixture) GetPR() *github.PullRequest

GetPR returns the fixture saved from the github.Client.PullRequests.Get output

func (Fixture) GetRevision

func (f Fixture) GetRevision(revision int) *Fixture

GetRevision returns a copy of this Fixture at a different revision

func (Fixture) GetRevisions

func (f Fixture) GetRevisions() []*Fixture

GetRevisions returns all this Fixture revisions, ordered from 0 to CurrentRevision

type Fixtures

type Fixtures []*Fixture

Fixtures is a list of fixtures. If a fixture has more than one revision the most recent one is used

func (Fixtures) GetByName

func (g Fixtures) GetByName(name string) *Fixture

GetByName returns fixture by name. If the fixture has more than one revision the most recent one is used

type PullRequestURL

type PullRequestURL struct {
	Owner  string
	Repo   string
	Number int
}

PullRequestURL is a struct with information about a pull request URL: github.com/<Owner>/<Repo>/pull/<Number>

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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