testutils

package
v0.0.0-...-742b54a Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ItemDefaultContent is the default content of the item.
	ItemDefaultContent = "test-content"

	// ItemDefaultContentSHA is the SHA256 hash of the default item content.
	ItemDefaultContentSHA = "0a3666a0710c08aa6d0de92ce72beeb5b93124cce1bf3701c9d6cdeb543cb73e"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ItemMock

type ItemMock struct {
	// contains filtered or unexported fields
}

ItemMock is a mock for a product version item (file) structure.

func MockItem

func MockItem(name string) ItemMock

MockItem initializes new product version item mock. By default, the item content is set to ItemDefaultContent.

func (ItemMock) AbsPath

func (c ItemMock) AbsPath() string

func (*ItemMock) Create

func (i *ItemMock) Create(t *testing.T, rootDir string) ItemMock

Create creates a mocked file in the given root directory.

func (ItemMock) RelPath

func (c ItemMock) RelPath() string

func (ItemMock) RootDir

func (c ItemMock) RootDir() string

func (ItemMock) WithContent

func (i ItemMock) WithContent(lines ...string) ItemMock

WithContent sets the content of the item.

type Mock

type Mock interface {
	RootDir() string
	RelPath() string
	AbsPath() string
}

Mock is an interface for all mock types.

type ProductMock

type ProductMock struct {
	// contains filtered or unexported fields
}

ProductMock is a mock for a product directory structure.

func MockProduct

func MockProduct(productRelPath string) ProductMock

MockProduct initializes new product mock.

func (ProductMock) AbsPath

func (c ProductMock) AbsPath() string

func (ProductMock) AddProductCatalog

func (p ProductMock) AddProductCatalog() ProductMock

AddProductCatalog creates product catalog from the current directory structure. It sets a checkpoint for the current state of the product. When the product is being created, catalog will be built when the product reaches that state.

func (ProductMock) AddVersions

func (p ProductMock) AddVersions(versions ...VersionMock) ProductMock

AddVersions adds mocked versions to the product.

func (*ProductMock) Create

func (p *ProductMock) Create(t *testing.T, rootDir string) ProductMock

Create creates the mocked product directory structure in the given directory. According to the mock's configuration, product catalog and config are created.

func (ProductMock) RelPath

func (c ProductMock) RelPath() string

func (ProductMock) RootDir

func (c ProductMock) RootDir() string

func (ProductMock) SetFilesAge

func (p ProductMock) SetFilesAge(age time.Duration) ProductMock

SetFilesAge modifies age (modification time) of the product files It sets a checkpoint for the current state of the product. When the product is being created, files age will be modified once the product reaches that state.

func (ProductMock) StreamName

func (p ProductMock) StreamName() string

StreamName returns the name of the product's stream.

type VersionMock

type VersionMock struct {
	// contains filtered or unexported fields
}

VersionMock is a mock for a product version directory structure.

func MockVersion

func MockVersion(versionRelPath string) VersionMock

MockVersion initializes new product version mock.

func (VersionMock) AbsPath

func (c VersionMock) AbsPath() string

func (VersionMock) AddItems

func (v VersionMock) AddItems(items ...ItemMock) VersionMock

AddItems adds mocked items to the version.

func (*VersionMock) Create

func (v *VersionMock) Create(t *testing.T, rootDir string) VersionMock

Create creates the mocked version directory structure in the given directory.

func (VersionMock) RelPath

func (c VersionMock) RelPath() string

func (VersionMock) RootDir

func (c VersionMock) RootDir() string

func (VersionMock) SetChecksums

func (v VersionMock) SetChecksums(entries ...string) VersionMock

SetChecksums stores the checksum entries that are written to a file when version is created.

func (VersionMock) SetImageConfig

func (v VersionMock) SetImageConfig(lines ...string) VersionMock

SetImageConfig sets image config with the given content that is written when a product version is created.

func (VersionMock) WithAge

func (v VersionMock) WithAge(age time.Duration) VersionMock

WithAge sets age (modification time) of the version contents after version is created.

func (VersionMock) WithFiles

func (v VersionMock) WithFiles(names ...string) VersionMock

WithFiles mocks default versions items with the given names. This is used as a shorthand for creating multiple items with the same content.

Jump to

Keyboard shortcuts

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