test

package
v0.0.0-...-2435b8f Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeIntoTestDir

func ChangeIntoTestDir(testDir string) (string, error)

ChangeIntoTestDir changes into test directory and returns the original. Note: make sure to call defer os.Chdir(original) after using this!

func CheckFailureContainsContent

func CheckFailureContainsContent(expected []*rpcpb.AnalysisFailure, actual []*rpcpb.AnalysisFailure) (bool, string)

CheckFailureContainsContent checks that there is a 1:1 mapping from expected failures to actual faulres. The description in the execpted failure needs only to be a substring of the actual failure. Returns whether such a 1:1 mapping exists, and if not, a message to print to the tests of the unmatched results

func CheckNoteContainsContent

func CheckNoteContainsContent(expected []*notepb.Note, actual []*notepb.Note) (bool, string)

CheckNoteContainsContent checks that there is a 1:1 mapping from expected notes to actual notes. The description in the execpted note needs only to be a substring of the actual note. Returns whether such a 1:1 mapping exists, and if not, a message to print to the tests of the unmatched results

func CreateContext

func CreateContext(testDir string, filepaths []string) (*ctxpb.ShipshapeContext, error)

CreateContext returns a new Shipshape test context

func CreateLocation

func CreateLocation(path string) *notepb.Location

func CreatekRPCTestServer

func CreatekRPCTestServer(dispatcher interface{}, name string) (string, func(), error)

func Match

func Match(expect *notepb.Note, actual *notepb.Note) bool

Match determines whether the actual note matches our expected note. It requires that the category, subcategory, and location.path be the same, and it requires that the actual description contain the expected description (to make tests easier to write, the actual description is allowed to have more text. Other fields are not checked.

func MatchFailure

func MatchFailure(expect *rpcpb.AnalysisFailure, actual *rpcpb.AnalysisFailure) bool

MatchFailure determines whether the actual failure matches our expected failure. It requires that the category be the same, and it requires that the actual description contain the expected description (to make tests easier to write, the actual description is allowed to have more text.

func RunAnalyzer

func RunAnalyzer(ctx *ctxpb.ShipshapeContext, a Analyzer, t *testing.T) ([]*notepb.Note, error)

RunAnalyzer does any preparation for running the analyzer, and runs it. Errors from setup/teardown will cause the test t to stop. Errors from the analysis will be returned, along with the notes

Types

type Analyzer

type Analyzer interface {
	Analyze(*ctxpb.ShipshapeContext) ([]*notepb.Note, error)
}

Jump to

Keyboard shortcuts

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