Files
troubleshoot/pkg/analyze/comparison_test.go
Evans Mungai db871e6889 feat: node metrics analyser (#1520)
* feat: node metrics analyser

The analyser only checks PVC usage at the moment. More analysers
can be added on a need to have basis

* Add tests

* Fix flaky test by waiting for goldpinger pods to start

* Fix how outcomes get checked

* Fix catch all outcome condition

* Fix test

* feat: node metrics analyser

The analyser only checks PVC usage at the moment. More analysers
can be added on a need to have basis

* Add tests

* Fix flaky test by waiting for goldpinger pods to start

* Fix how outcomes get checked

* Fix catch all outcome condition

* Fix test

* Regenerate schemas

* Fix failing test

---------

Co-authored-by: Dexter Yan <yanshaocong@gmail.com>
2024-04-09 12:14:10 +01:00

80 lines
1.3 KiB
Go

package analyzer
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseComparisonOperator(t *testing.T) {
tests := []struct {
name string
input string
want ComparisonOperator
wantErr bool
}{
{
name: "equal",
input: "=",
want: Equal,
},
{
name: "equal",
input: "==",
want: Equal,
},
{
name: "equal",
input: "===",
want: Equal,
},
{
name: "not equal",
input: "!=",
want: NotEqual,
},
{
name: "not equal",
input: "!==",
want: NotEqual,
},
{
name: "less than",
input: "<",
want: LessThan,
},
{
name: "greater than",
input: ">",
want: GreaterThan,
},
{
name: "less than or equal",
input: "<=",
want: LessThanOrEqual,
},
{
name: "greater than or equal",
input: ">=",
want: GreaterThanOrEqual,
},
{
name: "invalid operator 1",
input: "",
wantErr: true,
},
{
name: "invalid operator 2",
input: "gibberish",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ParseComparisonOperator(tt.input)
assert.Equal(t, tt.want, got, "ParseOperator() = %v, want %v", got, tt.want)
assert.Equalf(t, tt.wantErr, err != nil, "ParseOperator() error = %v, wantErr %v", err, tt.wantErr)
})
}
}