testutil

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromFixture

func LoadFromFixture(
	fixturePath string,
	output interface{},
)

LoadFromFixture fills an empty pointer variable with the data from a fixture JSON/YAML file.

Types

type Expect

type Expect struct {
	LatestState string `json:"latest_state"`
	// Error is a string matching the message of the expected error returned from the ResourceManager operation.
	// Possible errors can be found in runtime/pkg/errors/error.go
	Error string `json:"error"`
}

Expect represents test scenario expected outcome fixture to load from file path

type Fixture

type Fixture struct {
	// DesiredState lets you specify fixture path to load the desired state fixture
	DesiredState string `json:"desired_state"`
	// LatestState lets you specify fixture path to load the current state fixture
	LatestState string `json:"latest_state"`
	// ServiceAPIs lets you specify fixture path to mock service sdk api response
	ServiceAPIs []ServiceAPI `json:"svc_api"`
}

Fixture represents test scenario fixture to load from file paths

type ServiceAPI

type ServiceAPI struct {
	Operation       string           `json:"operation"`
	Output          string           `json:"output_fixture,omitempty"`
	ServiceAPIError *ServiceAPIError `json:"error,omitempty"`
}

ServiceAPI represents details about the the service sdk api and fixture path to mock its response

type ServiceAPIError

type ServiceAPIError struct {
	// Code here is usually the type of fault/error, not the HTTP status code
	Code    string `json:"code"`
	Message string `json:"message"`
}

ServiceAPIError contains the specification for the error of the mock API response

type TestConfig

type TestConfig struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Scenarios   []TestScenario `json:"scenarios"`
}

TestConfig represents declarative unit test

type TestScenario

type TestScenario struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	// Fixture lets you specify test scenario given input fixtures
	Fixture Fixture `json:"given"`
	// UnitUnderTest lets you specify the unit to test
	// For example resource manager API: ReadOne, Create, Update, Delete
	UnitUnderTest string `json:"invoke"`
	// Expect lets you specify test scenario expected outcome fixtures
	Expect Expect `json:"expect"`
}

TestScenario represents declarative test scenario details

type TestSuite

type TestSuite struct {
	Tests []TestConfig `json:"tests"`
}

TestSuite represents instructions to run unit tests using test fixtures and mock service apis

Jump to

Keyboard shortcuts

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