@@ -27,53 +27,95 @@ func TestV1beta1(t *testing.T) {
27
27
RunSpecs (t , "V1beta1 Suite" )
28
28
}
29
29
30
- var validKMs = []KernelMapping {
31
- {Regexp : "valid-regex" },
32
- }
33
-
34
- var invalidKMs = []KernelMapping {
35
- {Regexp : "*-invalid-regex" },
36
- }
37
-
38
- var module = & Module {
39
- Spec : ModuleSpec {
40
- ModuleLoader : ModuleLoaderSpec {
41
- Container : ModuleLoaderContainerSpec {
42
- KernelMappings : nil ,
43
- },
44
- },
45
- },
46
- }
47
-
48
- var _ = BeforeEach (func () {
49
- module .Spec .ModuleLoader .Container .KernelMappings = validKMs
50
- })
51
-
52
30
var _ = Describe ("ValidateCreate" , func () {
53
31
It ("should pass when all conditions are met" , func () {
32
+ module := & Module {
33
+ Spec : ModuleSpec {
34
+ ModuleLoader : ModuleLoaderSpec {
35
+ Container : ModuleLoaderContainerSpec {
36
+ KernelMappings : []KernelMapping {
37
+ {Regexp : "valid-regex" },
38
+ },
39
+ },
40
+ },
41
+ },
42
+ }
43
+
54
44
e := module .ValidateCreate ()
55
45
Expect (e ).To (BeNil ())
56
46
})
57
47
58
48
It ("should fail when an invalid regex is found" , func () {
59
- m := module
60
- m .Spec .ModuleLoader .Container .KernelMappings = invalidKMs
49
+ module := & Module {
50
+ Spec : ModuleSpec {
51
+ ModuleLoader : ModuleLoaderSpec {
52
+ Container : ModuleLoaderContainerSpec {
53
+ KernelMappings : []KernelMapping {
54
+ {Regexp : "*-invalid-regex" },
55
+ },
56
+ },
57
+ },
58
+ },
59
+ }
60
+
61
61
e := module .ValidateCreate ()
62
62
Expect (e ).To (HaveOccurred ())
63
- Expect (e .Error ()).To (ContainSubstring ("invalid regex: " ))
63
+ Expect (e .Error ()).To (ContainSubstring ("invalid regexp " ))
64
64
})
65
65
})
66
66
67
67
var _ = Describe ("ValidateUpdate" , func () {
68
68
It ("should pass when all conditions are met" , func () {
69
+ module := & Module {
70
+ Spec : ModuleSpec {
71
+ ModuleLoader : ModuleLoaderSpec {
72
+ Container : ModuleLoaderContainerSpec {
73
+ KernelMappings : []KernelMapping {
74
+ {Regexp : "valid-regex" },
75
+ },
76
+ },
77
+ },
78
+ },
79
+ }
80
+
69
81
e := module .ValidateUpdate (nil )
70
- Expect (e ).To (BeNil ())
82
+ Expect (e ).ToNot (HaveOccurred ())
83
+ })
84
+
85
+ It ("should fail when an invalid regex is found" , func () {
86
+ module := & Module {
87
+ Spec : ModuleSpec {
88
+ ModuleLoader : ModuleLoaderSpec {
89
+ Container : ModuleLoaderContainerSpec {
90
+ KernelMappings : []KernelMapping {
91
+ {Regexp : "*-invalid-regex" },
92
+ },
93
+ },
94
+ },
95
+ },
96
+ }
97
+
98
+ e := module .ValidateUpdate (nil )
99
+ Expect (e ).To (HaveOccurred ())
100
+ Expect (e .Error ()).To (ContainSubstring ("invalid regexp" ))
71
101
})
72
102
})
73
103
74
104
var _ = Describe ("ValidateDelete" , func () {
75
105
It ("should do nothing and return always nil" , func () {
106
+ module := & Module {
107
+ Spec : ModuleSpec {
108
+ ModuleLoader : ModuleLoaderSpec {
109
+ Container : ModuleLoaderContainerSpec {
110
+ KernelMappings : []KernelMapping {
111
+ {Regexp : "valid-regex" },
112
+ },
113
+ },
114
+ },
115
+ },
116
+ }
117
+
76
118
e := module .ValidateDelete ()
77
- Expect (e ).To ( BeNil ())
119
+ Expect (e ).ToNot ( HaveOccurred ())
78
120
})
79
121
})
0 commit comments