add additional test cases to the host os info analyzer (#1754)

This commit is contained in:
Andrew Lavery
2025-03-06 17:57:59 -05:00
committed by GitHub
parent 3665d25abf
commit 9d9b3c565c
3 changed files with 22 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect

View File

@@ -43,6 +43,7 @@ github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYu
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=

View File

@@ -160,6 +160,26 @@ func TestAnalyzeHostOSCheckCondition(t *testing.T) {
expected: false,
expectErr: false,
},
{
name: "multiple conditionals, outside the three",
conditional: "redhat >= 8 && < 9 || == 9.1.0",
osInfo: collect.HostOSInfo{
Platform: "redhat",
PlatformVersion: "9.2",
},
expected: false,
expectErr: false,
},
{
name: "multiple conditionals, matches the third",
conditional: "redhat >= 8 && < 9 || == 9.2.0",
osInfo: collect.HostOSInfo{
Platform: "redhat",
PlatformVersion: "9.2",
},
expected: true,
expectErr: false,
},
}
for _, test := range tests {