@@ -49,6 +49,47 @@ func TestAnalyzeHostOSCheckCondition(t *testing.T) {
4949 expected : true ,
5050 expectErr : false ,
5151 },
52+ {
53+ name : "centos < 8 when actual is 7.2" ,
54+ conditional : "centos < 8" ,
55+ osInfo : collect.HostOSInfo {
56+ Platform : "centos" ,
57+ PlatformVersion : "7.2" ,
58+ },
59+ expected : true ,
60+ expectErr : false ,
61+ },
62+ {
63+ name : "centos < 8 when actual is 8.2" ,
64+ conditional : "centos < 8" ,
65+ osInfo : collect.HostOSInfo {
66+ Platform : "centos" ,
67+ PlatformVersion : "8.2" ,
68+ },
69+ expected : false ,
70+ expectErr : false ,
71+ },
72+ {
73+ name : "centos < 8 when actual is rhel 7.2" , // this tests that we properly exclude other OSes despite the version matching
74+ conditional : "centos < 8" ,
75+ osInfo : collect.HostOSInfo {
76+ Platform : "redhat" ,
77+ PlatformVersion : "7.2" ,
78+ },
79+ expected : false ,
80+ expectErr : false ,
81+ },
82+ {
83+ name : "rhel == 8.2 when actual is 8.2" , // this tests that we match on either platform or platform family
84+ conditional : "rhel == 8.2" ,
85+ osInfo : collect.HostOSInfo {
86+ Platform : "centos" ,
87+ PlatformFamily : "rhel" ,
88+ PlatformVersion : "8.2" ,
89+ },
90+ expected : true ,
91+ expectErr : false ,
92+ },
5293 {
5394 name : "ubuntu == 20.04 when actual is 18.04" ,
5495 conditional : "ubuntu == 20.04" ,
@@ -69,6 +110,56 @@ func TestAnalyzeHostOSCheckCondition(t *testing.T) {
69110 expected : false ,
70111 expectErr : true ,
71112 },
113+ {
114+ name : "multiple conditionals, neither true" ,
115+ conditional : "ubuntu > 20.04 || <= 18.04" ,
116+ osInfo : collect.HostOSInfo {
117+ Platform : "ubuntu" ,
118+ PlatformVersion : "20.04" ,
119+ },
120+ expected : false ,
121+ expectErr : false ,
122+ },
123+ {
124+ name : "multiple conditionals, first true" ,
125+ conditional : "ubuntu > 20.04 || <= 18.04" ,
126+ osInfo : collect.HostOSInfo {
127+ Platform : "ubuntu" ,
128+ PlatformVersion : "22.04" ,
129+ },
130+ expected : true ,
131+ expectErr : false ,
132+ },
133+ {
134+ name : "multiple conditionals, second true" ,
135+ conditional : "ubuntu > 20.04 || <= 18.04" ,
136+ osInfo : collect.HostOSInfo {
137+ Platform : "ubuntu" ,
138+ PlatformVersion : "18.04" ,
139+ },
140+ expected : true ,
141+ expectErr : false ,
142+ },
143+ {
144+ name : "multiple conditionals, between the two" ,
145+ conditional : "redhat >= 8 && < 9" ,
146+ osInfo : collect.HostOSInfo {
147+ Platform : "redhat" ,
148+ PlatformVersion : "8.2" ,
149+ },
150+ expected : true ,
151+ expectErr : false ,
152+ },
153+ {
154+ name : "multiple conditionals, outside the two" ,
155+ conditional : "redhat >= 8 && < 9" ,
156+ osInfo : collect.HostOSInfo {
157+ Platform : "redhat" ,
158+ PlatformVersion : "9.2" ,
159+ },
160+ expected : false ,
161+ expectErr : false ,
162+ },
72163 }
73164
74165 for _ , test := range tests {
0 commit comments