@@ -4,27 +4,20 @@ import (
4
4
"testing"
5
5
6
6
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
7
- "github.com/replicatedhq/troubleshoot/pkg/collect"
8
7
"github.com/stretchr/testify/assert"
9
8
)
10
9
11
10
func TestAnalyzeKernelConfigs (t * testing.T ) {
12
- kConfigs := collect.KConfigs {
13
- "CONFIG_CGROUP_FREEZER" : "y" ,
14
- "CONFIG_NETFILTER_XTABLES" : "m" ,
15
- }
16
11
17
12
tests := []struct {
18
13
name string
19
- kConfigs collect.KConfigs
20
14
selectedConfigs []string
21
15
outcomes []* troubleshootv1beta2.Outcome
22
16
results []* AnalyzeResult
23
17
expectErr bool
24
18
}{
25
19
{
26
20
name : "all pass" ,
27
- kConfigs : kConfigs ,
28
21
selectedConfigs : []string {"CONFIG_CGROUP_FREEZER=y" , "CONFIG_NETFILTER_XTABLES=m" },
29
22
outcomes : []* troubleshootv1beta2.Outcome {
30
23
{
@@ -44,7 +37,6 @@ func TestAnalyzeKernelConfigs(t *testing.T) {
44
37
},
45
38
{
46
39
name : "has fail" ,
47
- kConfigs : kConfigs ,
48
40
selectedConfigs : []string {"CONFIG_UTS_NS=y" },
49
41
outcomes : []* troubleshootv1beta2.Outcome {
50
42
{
@@ -64,7 +56,6 @@ func TestAnalyzeKernelConfigs(t *testing.T) {
64
56
},
65
57
{
66
58
name : "kernel config disabled" ,
67
- kConfigs : kConfigs ,
68
59
selectedConfigs : []string {"CONFIG_CGROUP_FREEZER=n" },
69
60
outcomes : []* troubleshootv1beta2.Outcome {
70
61
{
@@ -84,17 +75,35 @@ func TestAnalyzeKernelConfigs(t *testing.T) {
84
75
},
85
76
{
86
77
name : "invalid kernel config" ,
87
- kConfigs : kConfigs ,
88
78
selectedConfigs : []string {"foobar=n" },
89
79
expectErr : true ,
90
80
},
81
+ {
82
+ name : "select multiple kernel config values" ,
83
+ selectedConfigs : []string {"CONFIG_BRIDGE=my" },
84
+ outcomes : []* troubleshootv1beta2.Outcome {
85
+ {
86
+ Pass : & troubleshootv1beta2.SingleOutcome {
87
+ Message : "required kernel configs are available" ,
88
+ },
89
+ },
90
+ },
91
+ results : []* AnalyzeResult {
92
+ {
93
+ Title : "Kernel Configs" ,
94
+ IsPass : true ,
95
+ Message : "required kernel configs are available" ,
96
+ },
97
+ },
98
+ expectErr : false ,
99
+ },
91
100
}
92
101
93
102
for _ , tt := range tests {
94
103
t .Run (tt .name , func (t * testing.T ) {
95
104
96
- fn := func (_ string ) ([]byte , error ) {
97
- return []byte (`{"CONFIG_CGROUP_FREEZER": "y", "CONFIG_NETFILTER_XTABLES": "m"}` ), nil
105
+ mockKernelFile := func (_ string ) ([]byte , error ) {
106
+ return []byte (`{"CONFIG_CGROUP_FREEZER": "y", "CONFIG_NETFILTER_XTABLES": "m", "CONFIG_BRIDGE": "y" }` ), nil
98
107
}
99
108
100
109
analyzer := AnalyzeHostKernelConfigs {
@@ -107,7 +116,7 @@ func TestAnalyzeKernelConfigs(t *testing.T) {
107
116
},
108
117
}
109
118
110
- results , err := analyzer .Analyze (fn , nil )
119
+ results , err := analyzer .Analyze (mockKernelFile , nil )
111
120
112
121
if tt .expectErr {
113
122
assert .Error (t , err )
0 commit comments