Documentation
¶
Overview ¶
Package testcmd provides utilities for testing osv-scanner CLI commands.
Index ¶
- Variables
- func CopyFileFlagTo(t *testing.T, tc Case, flagName string, dir string) string
- func InsertCassette(t *testing.T) *http.Client
- func RunAndMatchSnapshots(t *testing.T, tc Case)
- func RunAndNormalize(t *testing.T, tc Case) (string, string)
- func SetupGitFixtures() (func(), error)
- func WithTestNameHeader(t *testing.T, client http.Client) *http.Client
- type Case
Constants ¶
This section is empty.
Variables ¶
var CommandsUnderTest []cmd.CommandBuilder
CommandsUnderTest should be set in TestMain by every cmd package test
Functions ¶
func CopyFileFlagTo ¶ added in v2.2.0
CopyFileFlagTo creates a copy of the file pointed to by the given flag (if present in the test case arguments) in the given directory, updating all references in the arguments before returning the new path.
Values that include "does_not_exist" are assumed to be for testing when the flag is given the path to a file or directory that does not exist, and so are ignored as if the flag was not given a value at all
func InsertCassette ¶ added in v2.3.1
InsertCassette returns an http.Client backed by a recorder.Recorder which will record and (re)play responses from a cassette based on the tests name
func RunAndMatchSnapshots ¶
func SetupGitFixtures ¶ added in v2.2.2
func SetupGitFixtures() (func(), error)
Types ¶
type Case ¶
type Case struct {
Name string
Args []string
Exit int
// ReplaceRules are only used for JSON output
ReplaceRules []testutility.JSONReplaceRule
HTTPClient *http.Client
}