Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
tests: Increase unit-test coverage on create.go
Browse files Browse the repository at this point in the history
Added 19 new tests. Coverage (when run as root) is 90.3% (actually,
94.6% when combining root and non-root test runs (some tests require
non-root to run)).

Fixes #401.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Aug 24, 2017
1 parent 2cac62a commit d9413e7
Show file tree
Hide file tree
Showing 2 changed files with 989 additions and 5 deletions.
14 changes: 10 additions & 4 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ var createCLICommand = cli.Command{
},
}

// Use a variable to allow tests to modify its value
var getKernelParamsFunc = getKernelParams

func create(containerID, bundlePath, console, pidFilePath string, detach bool,
runtimeConfig oci.RuntimeConfig) error {
var err error
Expand Down Expand Up @@ -144,10 +147,8 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
return nil
}

func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
containerID, bundlePath, console string, disableOutput bool) (vc.Process, error) {

ccKernelParams := []vc.Param{
func getKernelParams(containerID string) []vc.Param {
return []vc.Param{
{
Key: "init",
Value: "/usr/lib/systemd/systemd",
Expand All @@ -169,6 +170,11 @@ func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
Value: fmt.Sprintf("::::::%s::off::", containerID),
},
}
}

func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
containerID, bundlePath, console string, disableOutput bool) (vc.Process, error) {
ccKernelParams := getKernelParamsFunc(containerID)

for _, p := range ccKernelParams {
if err := (&runtimeConfig).AddKernelParam(p); err != nil {
Expand Down
Loading

0 comments on commit d9413e7

Please # to comment.