Skip to content

Commit

Permalink
Changed according to the comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Milchev fixed-term.daniel.milchev@bosch.io
  • Loading branch information
daniel-milchev committed Oct 24, 2023
1 parent 8a5786c commit 3df3168
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
16 changes: 16 additions & 0 deletions containerm/ctr/ctrd_client_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ func TestConfigureRuncRuntime(t *testing.T) {
},
runtime: ctrdClient.runcRuntime,
},
"RuntimeTypeV2runcV1": {
container: &types.Container{
HostConfig: &types.HostConfig{
Runtime: types.RuntimeTypeV2runcV1,
},
},
runtime: ctrdClient.runcRuntime,
},
"RuntimeTypeV2runcV2": {
container: &types.Container{
HostConfig: &types.HostConfig{
Runtime: types.RuntimeTypeV2runcV2,
},
},
runtime: ctrdClient.runcRuntime,
},
"test_default": {
container: &types.Container{
HostConfig: &types.HostConfig{
Expand Down
28 changes: 9 additions & 19 deletions containerm/ctr/ctrd_container_create_opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
func TestWithRuntimeOpts(t *testing.T) {
tests := map[string]struct {
container *types.Container
runtimeRootPath string
}{
"test_runtime_type_v1": {
&types.Container{
Expand All @@ -34,7 +33,6 @@ func TestWithRuntimeOpts(t *testing.T) {
Runtime: types.RuntimeTypeV1,
},
},
"",
},
"test_runtime_type_v2": {
&types.Container{
Expand All @@ -44,7 +42,6 @@ func TestWithRuntimeOpts(t *testing.T) {
Runtime: types.RuntimeTypeV2runcV1,
},
},
"",
},
"testing_default": {
&types.Container{
Expand All @@ -54,54 +51,47 @@ func TestWithRuntimeOpts(t *testing.T) {
Runtime: "",
},
},
"",
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
got := WithRuntimeOpts(test.container, test.runtimeRootPath)
got := WithRuntimeOpts(test.container, "")
testutil.AssertNotNil(t, got)
})
}
}

func TestWithSpecOpts(t *testing.T) {

tests := map[string]struct {
container *types.Container
image containerd.Image
execRoot string
}{
"test_privileged": {
"test_config": {
&types.Container{
Config: &types.ContainerConfiguration{
Cmd: []string{"test"},
Env: []string{"test"},
},
HostConfig: &types.HostConfig{},
},
},
"test_privileged": {
&types.Container{
HostConfig: &types.HostConfig{
Privileged: true,
},
},
containerd.NewImage(&containerd.Client{}, images.Image{}),
"/tmp/test",
},
"test_extra_capabilities": {
&types.Container{
Config: &types.ContainerConfiguration{
Cmd: []string{"test"},
Env: []string{"test"},
},
HostConfig: &types.HostConfig{
ExtraCapabilities: []string{"CAP_NET_ADMIN"},
},
},
containerd.NewImage(&containerd.Client{}, images.Image{}),
"/tmp/test",
},
}
for name, tests := range tests {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
got := WithSpecOpts(tests.container, tests.image, tests.execRoot)
got := WithSpecOpts(test.container, containerd.NewImage(&containerd.Client{}, images.Image{}), "/tmp/test")
testutil.AssertNotNil(t, got)
})
}
Expand Down

0 comments on commit 3df3168

Please sign in to comment.