Documentation ¶
Index ¶
- Constants
- type ItemMock
- type Mock
- type ProductMock
- func (c ProductMock) AbsPath() string
- func (p ProductMock) AddProductCatalog() ProductMock
- func (p ProductMock) AddVersions(versions ...VersionMock) ProductMock
- func (p *ProductMock) Create(t *testing.T, rootDir string) ProductMock
- func (c ProductMock) RelPath() string
- func (c ProductMock) RootDir() string
- func (p ProductMock) SetFilesAge(age time.Duration) ProductMock
- func (p ProductMock) StreamName() string
- type VersionMock
- func (c VersionMock) AbsPath() string
- func (v VersionMock) AddItems(items ...ItemMock) VersionMock
- func (v *VersionMock) Create(t *testing.T, rootDir string) VersionMock
- func (c VersionMock) RelPath() string
- func (c VersionMock) RootDir() string
- func (v VersionMock) SetChecksums(entries ...string) VersionMock
- func (v VersionMock) SetImageConfig(lines ...string) VersionMock
- func (v VersionMock) WithAge(age time.Duration) VersionMock
- func (v VersionMock) WithFiles(names ...string) VersionMock
Constants ¶
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 ¶
MockItem initializes new product version item mock. By default, the item content is set to ItemDefaultContent.
func (ItemMock) WithContent ¶
WithContent sets the content of the item.
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) 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) 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) 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) 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.