testing

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareOutputWithFixture

func CompareOutputWithFixture(t *testing.T, testerOutput []byte, normalizeOutputFunc func([]byte) []byte, fixturePath string)

func IsRecordingOrEvaluatingFixtures

func IsRecordingOrEvaluatingFixtures() bool

IsRecordingOrEvaluatingFixtures can be used to run code required to control any external sources of randomness that can affect fixtures.

Use this sparingly, we don't want to introduce too much drift between our test environment and production.

Note: This is only needed to control *external* sources of randomness. Any random values generated by the tester should use tester_utils.random, which uses a fixed seed across all test runs.

func TestTesterOutput

func TestTesterOutput(t *testing.T, testerDefinition tester_definition.TesterDefinition, testCases map[string]TesterOutputTestCase)

func ValidateTesterDefinitionAgainstYAML

func ValidateTesterDefinitionAgainstYAML(t testing.T, testerDefinition tester_definition.TesterDefinition, yamlPath string)

ValidateTesterDefinitionAgainstYAML tests whether the stage slugs in TesterDefintion match those in the course YAML at yamlPath.

Types

type TesterOutputTestCase

type TesterOutputTestCase struct {
	// CodePath is the path to the code that'll be tested.
	CodePath string

	// ExpectedExitCode is the exit code that we expect the tester to return.
	ExpectedExitCode int

	// UntilStageSlug is the slug of the stage that we want to test until. Either this or StageSlug must be provided.
	UntilStageSlug string

	// SkipAntiCheat is a flag that indicates whether we want to skip the anti-cheat check.
	SkipAntiCheat *bool

	// StageSlugs is the list of stages that we want to test. Either this or UntilStageSlug must be provided.
	StageSlugs []string

	// StdoutFixturePath is the path to the fixture file that contains the expected stdout output.
	StdoutFixturePath string

	// NormalizeOutputFunc is a function that normalizes the tester's output. This is useful for removing things like timestamps.
	NormalizeOutputFunc func([]byte) []byte
}

Jump to

Keyboard shortcuts

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