-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall_test.go
More file actions
101 lines (96 loc) · 2.52 KB
/
install_test.go
File metadata and controls
101 lines (96 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main_test
import (
"testing"
"github.com/spf13/afero"
main "github.com/spinframework/runtime-class-manager/cmd/node-installer"
tests "github.com/spinframework/runtime-class-manager/tests/node-installer"
"github.com/stretchr/testify/require"
)
type nullRestarter struct{}
func (n nullRestarter) Restart() error {
return nil
}
func Test_RunInstall(t *testing.T) {
type args struct {
config main.Config
rootFs afero.Fs
hostFs afero.Fs
}
tests := []struct {
name string
args args
wantErr bool
}{
{
"new shim",
args{
main.Config{
struct {
Name string
ConfigPath string
Options map[string]string
}{"containerd", "/etc/containerd/config.toml", nil},
struct {
Path string
AssetPath string
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{"/containerd/missing-containerd-shim-config"},
},
tests.FixtureFs("../../testdata/node-installer"),
tests.FixtureFs("../../testdata/node-installer/containerd/missing-containerd-shim-config"),
},
false,
},
{
"existing shim",
args{
main.Config{
struct {
Name string
ConfigPath string
Options map[string]string
}{"containerd", "/etc/containerd/config.toml", nil},
struct {
Path string
AssetPath string
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{"/containerd/existing-containerd-shim-config"},
},
tests.FixtureFs("../../testdata/node-installer"),
tests.FixtureFs("../../testdata/node-installer/containerd/existing-containerd-shim-config"),
},
false,
},
{
// TODO figure out how to test that the runtime options are set in the config
"new shim with runtime options",
args{
main.Config{
struct {
Name string
ConfigPath string
Options map[string]string
}{"containerd", "/etc/containerd/config.toml", map[string]string{"SystemdCgroup": "true"}},
struct {
Path string
AssetPath string
}{"/opt/rcm", "/assets"},
struct{ RootPath string }{"/containerd/missing-containerd-shim-config"},
},
tests.FixtureFs("../../testdata/node-installer"),
tests.FixtureFs("../../testdata/node-installer/containerd/missing-containerd-shim-config"),
},
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := main.RunInstall(tt.args.config, tt.args.rootFs, tt.args.hostFs, nullRestarter{})
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
}