Documentation
¶
Index ¶
- Constants
- func NewDynamicTestProject(options ...DynamicTestProjectOption) *dynamicTestProject
- func NewTemplatedTestProject(t *testing.T, templateDir string, options ...TemplatedTestProjectOption) *templatedTestProject
- func TestDefaultConfigsDir() string
- type DynamicTestProjectOption
- type ProjectTest
- type ProjectTestOption
- type ProjectTestResults
- type TemplatedTestProjectOption
- type TestProject
- type TestSpec
- type TestSpecOption
Constants ¶
const ( // TestDefaultConfigsSubdir is the subdirectory name used for test default configs in the container. TestDefaultConfigsSubdir = "testdefaults" // TestDefaultConfigsIncludePath is the relative include path to use from a project's azldev.toml // to include the test default configs. This path is relative to the project directory. TestDefaultConfigsIncludePath = "../" + TestDefaultConfigsSubdir + "/defaults.toml" )
const NoArch = "noarch"
NoArch is a constant representing the "noarch" architecture for RPMs.
Variables ¶
This section is empty.
Functions ¶
func NewDynamicTestProject ¶
func NewDynamicTestProject(options ...DynamicTestProjectOption) *dynamicTestProject
NewDynamicProject dynamically constructs a new test project that can later be rendered to files and used in a test.
func NewTemplatedTestProject ¶
func NewTemplatedTestProject( t *testing.T, templateDir string, options ...TemplatedTestProjectOption, ) *templatedTestProject
func TestDefaultConfigsDir ¶
func TestDefaultConfigsDir() string
TestDefaultConfigsDir returns the absolute path to the scenario/testdata/defaultconfigs directory. This function uses runtime.Caller to resolve the path relative to this source file's location.
Types ¶
type DynamicTestProjectOption ¶
type DynamicTestProjectOption func(*dynamicTestProject)
TestProjectOption is a function that can be used to modify a TestProject in-place.
func AddComponent ¶
func AddComponent(componentConfig *projectconfig.ComponentConfig) DynamicTestProjectOption
AddComponents adds (or updates) the configuration for a component to the project. The provided configuration value will remain under the ownership of the caller.
func AddSpec ¶
func AddSpec(spec *TestSpec) DynamicTestProjectOption
AddSpec adds (or updates) the contents of a spec file to the project.
func UseTestDefaultConfigs ¶
func UseTestDefaultConfigs() DynamicTestProjectOption
UseTestDefaultConfigs configures the project to include the test default configs. This adds an include directive to the project's azldev.toml that references the test default configs (which must be copied into the container separately using WithTestDefaultConfigs on the ProjectTest).
type ProjectTest ¶
type ProjectTest struct {
// contains filtered or unexported fields
}
ProjectTest represents a runnable, project-oriented test case.
func NewProjectTest ¶
func NewProjectTest(project TestProject, commandArgs []string, options ...ProjectTestOption) *ProjectTest
NewProjectTest creates a new ProjectTest with the specified project and command arguments.
func (*ProjectTest) RunInContainer ¶
func (p *ProjectTest) RunInContainer(t *testing.T) *ProjectTestResults
RunInContainer runs the project test in a container, returning results.
type ProjectTestOption ¶
type ProjectTestOption func(*ProjectTest)
ProjectTestOption is a function that can be used to configure a ProjectTest.
func WithTestDefaultConfigs ¶
func WithTestDefaultConfigs() ProjectTestOption
WithTestDefaultConfigs configures the project test to copy and use the test default configs. When enabled, the test default configs from scenario/testdata/defaultconfigs/ will be copied into the container and made available for the project to include.
type ProjectTestResults ¶
type ProjectTestResults struct {
// contains filtered or unexported fields
}
ProjectTestResults encapsulates the results of running a ProjectTest in a container.
func (*ProjectTestResults) GetInContainerProjectPath ¶
func (r *ProjectTestResults) GetInContainerProjectPath(pathComponents ...string) string
GetInContainerProjectPath returns the path to the project directory inside the container.
func (*ProjectTestResults) GetJSONResult ¶
func (r *ProjectTestResults) GetJSONResult() []map[string]any
GetJSONResult returns the parsed JSON output of the command-under-test's output.
func (*ProjectTestResults) GetProjectOutputPath ¶
func (r *ProjectTestResults) GetProjectOutputPath(pathComponents ...string) string
GetProjectOutputPath returns the path to the project output directory on the host.
func (*ProjectTestResults) GetRawJSONBytes ¶
func (r *ProjectTestResults) GetRawJSONBytes() []byte
GetRawJSONBytes returns the raw JSON bytes of the command-under-test's output.
type TemplatedTestProjectOption ¶
type TemplatedTestProjectOption func(*templatedTestProject)
TemplatedTestProjectOption is a function that can be used to configure a [templatedTestProject].
func TemplatedUseTestDefaultConfigs ¶
func TemplatedUseTestDefaultConfigs() TemplatedTestProjectOption
TemplatedUseTestDefaultConfigs configures the templated project to include the test default configs. This modifies the project's azldev.toml after copying to add an include directive that references the test default configs (which must be copied into the container separately using WithTestDefaultConfigs on the ProjectTest).
type TestProject ¶
type TestProject interface {
// Serialize writes the project to the given directory.
Serialize(t *testing.T, projectDir string)
}
TestProject is implemented by types that can produce a serial azldev project directory.
type TestSpec ¶
type TestSpec struct {
// contains filtered or unexported fields
}
TestSpec represents an RPM spec being composed for testing purposes.
func NewSpec ¶
func NewSpec(options ...TestSpecOption) *TestSpec
NewSpec creates a new TestSpec with the specified options.
func (*TestSpec) GetRelease ¶
GetRelease returns the release of the component defined by the spec.
func (*TestSpec) GetVersion ¶
GetVersion returns the version of the component defined by the spec.
type TestSpecOption ¶
type TestSpecOption func(*TestSpec)
TestSpecOption is a function that can be used to modify a TestSpec in-place.
func WithBuildArch ¶
func WithBuildArch(arch string) TestSpecOption
WithBuildArch sets the build architecture of the component defined by the spec.
func WithName ¶
func WithName(name string) TestSpecOption
WithName sets the name of the component defined by the spec.
func WithRelease ¶
func WithRelease(release string) TestSpecOption
WithRelease sets the release of the component defined by the spec.
func WithVersion ¶
func WithVersion(version string) TestSpecOption
WithVersion sets the version of the component defined by the spec.