Documentation ¶
Overview ¶
Package snaptest contains helper functions for mocking snaps.
Index ¶
- func AssertedSnapID(snapName string) string
- func MakeSnapFileAndDir(c *check.C, snapYamlContent string, files [][]string, si *snap.SideInfo) *snap.Info
- func MakeTestComponent(c *check.C, compYaml string) string
- func MakeTestComponentWithFiles(c *check.C, componentName, componentYaml string, files [][]string) (snapFilePath string)
- func MakeTestSnapInfoWithFiles(c *check.C, snapYamlContent string, files [][]string, si *snap.SideInfo) (snapFilePath string, info *snap.Info)
- func MakeTestSnapWithFiles(c *check.C, snapYamlContent string, files [][]string) (snapFilePath string)
- func MockComponent(c *check.C, yamlText string, info *snap.Info, csi snap.ComponentSideInfo) *snap.ComponentInfo
- func MockComponentCurrent(c *check.C, yamlText string, info *snap.Info, csi snap.ComponentSideInfo) *snap.ComponentInfo
- func MockContainer(c *check.C, files [][]string) snap.Container
- func MockInfo(c *check.C, yamlText string, sideInfo *snap.SideInfo) *snap.Info
- func MockInvalidInfo(c *check.C, yamlText string, sideInfo *snap.SideInfo) *snap.Info
- func MockSnap(c *check.C, yamlText string, sideInfo *snap.SideInfo) *snap.Info
- func MockSnapCurrent(c *check.C, yamlText string, sideInfo *snap.SideInfo) *snap.Info
- func MockSnapInstance(c *check.C, instanceName, yamlText string, sideInfo *snap.SideInfo) *snap.Info
- func MockSnapInstanceCurrent(c *check.C, instanceName, yamlText string, sideInfo *snap.SideInfo) *snap.Info
- func MockSnapWithFiles(c *check.C, yamlText string, si *snap.SideInfo, files [][]string) *snap.Info
- func MustParseChannel(s string, architecture string) channel.Channel
- func PopulateDir(dir string, files [][]string)
- func RenameSlot(snapInfo *snap.Info, oldName, newName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertedSnapID ¶
func MakeSnapFileAndDir ¶
func MakeSnapFileAndDir(c *check.C, snapYamlContent string, files [][]string, si *snap.SideInfo) *snap.Info
MakeSnapFileAndDir makes a squashfs snap file and a directory under /snaps/<snap>/<rev> with the given contents. It's a combined effect of MakeTestSnapInfoWithFiles and MockSnapWithFiles.
func MakeTestComponent ¶
func MakeTestComponentWithFiles ¶
func MakeTestComponentWithFiles(c *check.C, componentName, componentYaml string, files [][]string) (snapFilePath string)
MakeTestComponentWithFiles builds a snap component container with a given name and content for component.yaml, populating additionally the squashfs with files if required.
func MakeTestSnapInfoWithFiles ¶
func MakeTestSnapInfoWithFiles(c *check.C, snapYamlContent string, files [][]string, si *snap.SideInfo) (snapFilePath string, info *snap.Info)
MakeTestSnapInfoWithFiles makes a squashfs snap file with the given snap.yaml content and optional extra files specified as pairs of relative file path and it's contents, and returns the path to the snap file and a suitable snap.Info for the snap
func MakeTestSnapWithFiles ¶
func MakeTestSnapWithFiles(c *check.C, snapYamlContent string, files [][]string) (snapFilePath string)
MakeTestSnapWithFiles makes a squashfs snap file with the given snap.yaml content and optional extras files specified as pairs of relative file path and its content.
func MockComponent ¶
func MockComponent(c *check.C, yamlText string, info *snap.Info, csi snap.ComponentSideInfo) *snap.ComponentInfo
MockComponent puts a component.yaml file on disk so to mock an installed component, based on the provided arguments.
The caller is responsible for mocking root directory with dirs.SetRootDir() and for altering the overlord state if required.
func MockComponentCurrent ¶
func MockComponentCurrent(c *check.C, yamlText string, info *snap.Info, csi snap.ComponentSideInfo) *snap.ComponentInfo
func MockContainer ¶
MockContainer returns a mock snap.Container with the given content. If files is empty it still produces a minimal container that passes ValidateContainer: / and /meta exist and are 0755, and /meta/snap.yaml is a regular world-readable file.
func MockInfo ¶
MockInfo parses the given snap.yaml text and returns a validated snap.Info object including the optional SideInfo.
The result is just kept in memory, there is nothing kept on disk. If that is desired please use MockSnap instead.
func MockInvalidInfo ¶
MockInvalidInfo parses the given snap.yaml text and returns the snap.Info object including the optional SideInfo.
The result is just kept in memory, there is nothing kept on disk. If that is desired please use MockSnap instead.
func MockSnap ¶
MockSnap puts a snap.yaml file on disk so to mock an installed snap, based on the provided arguments.
The caller is responsible for mocking root directory with dirs.SetRootDir() and for altering the overlord state if required.
func MockSnapCurrent ¶
MockSnapCurrent does the same as MockSnap but additionally creates the 'current' symlink.
The caller is responsible for mocking root directory with dirs.SetRootDir() and for altering the overlord state if required.
func MockSnapInstance ¶
func MockSnapInstance(c *check.C, instanceName, yamlText string, sideInfo *snap.SideInfo) *snap.Info
MockSnapInstance puts a snap.yaml file on disk so to mock an installed snap instance, based on the provided arguments.
The caller is responsible for mocking root directory with dirs.SetRootDir() and for altering the overlord state if required.
func MockSnapInstanceCurrent ¶
func MockSnapInstanceCurrent(c *check.C, instanceName, yamlText string, sideInfo *snap.SideInfo) *snap.Info
MockSnapInstanceCurrent does the same as MockSnapInstance but additionally creates the 'current' symlink.
The caller is responsible for mocking root directory with dirs.SetRootDir() and for altering the overlord state if required.
func MockSnapWithFiles ¶
MockSnapWithFiles does the same as MockSnap, but also populates the snap directory with given content
The caller is responsible for mocking root directory with dirs.SetRootDir() and for altering the overlord state if required.
func MustParseChannel ¶
MustParseChannel parses a string representing a store channel and includes the given architecture, if architecture is "" the system architecture is included. It panics on error.
func PopulateDir ¶
PopulateDir populates the directory with files specified as pairs of relative file path and its content. Useful to add extra files to a snap.
Types ¶
This section is empty.