Skip to content

Commit

Permalink
tests: Increase unit-test coverage on create.go
Browse files Browse the repository at this point in the history
Added 18 new tests. Coverage (when run as root) is 87.1% (actually,
it's higher since some tests require non-root to run).

Fixes clearcontainers#401.

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

var getKernelParamsFunc func(containerID string) []vc.Param = getKernelParams

func create(containerID, bundlePath, console, pidFilePath string, detach bool,
runtimeConfig oci.RuntimeConfig) error {
var err error
Expand Down Expand Up @@ -144,10 +146,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 +169,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 b568054

Please # to comment.