From 3cd80e44874166f9212198b53848b2e2cf441999 Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Wed, 27 Sep 2023 10:08:50 -0400 Subject: [PATCH] :ghost: add more tests Signed-off-by: Pranav Gaikwad --- engine/labels/labels_test.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/engine/labels/labels_test.go b/engine/labels/labels_test.go index 3e0881d7..697ee4d7 100644 --- a/engine/labels/labels_test.go +++ b/engine/labels/labels_test.go @@ -90,6 +90,22 @@ func Test_getBooleanExpression(t *testing.T) { }, want: "( true || true ) && false && true", }, + { + name: "values with version ranges", + expr: "(konveyor.io/target=Spring Beans12 && konveyor.io/target=hibernate6.1)", + compareLabels: map[string][]string{ + "konveyor.io/target": {"hibernate6-", "Spring Beans11+"}, + }, + want: "( true && false )", + }, + { + name: "values with version ranges", + expr: "(konveyor.io/target=Spring Beans12 && konveyor.io/target=hibernate6.1)", + compareLabels: map[string][]string{ + "konveyor.io/target": {"hibernate6+", "Spring Beans11-"}, + }, + want: "( false && true )", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -160,11 +176,23 @@ func TestParseLabel(t *testing.T) { wantVal: "Spring Beans", }, { - name: "version ranges in values", + name: "absolte version in value", label: "konveyor.io/fact=Spring Beans12", wantKey: "konveyor.io/fact", wantVal: "Spring Beans12", }, + { + name: "version range + in value", + label: "konveyor.io/fact=Spring Beans12+", + wantKey: "konveyor.io/fact", + wantVal: "Spring Beans12+", + }, + { + name: "version range - in value", + label: "konveyor.io/fact=Spring Beans12-", + wantKey: "konveyor.io/fact", + wantVal: "Spring Beans12-", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {