From 8d38c84713cdd7b569452de8807d6d3857caa38c Mon Sep 17 00:00:00 2001 From: Arjun Khunti Date: Tue, 31 Oct 2023 15:20:56 +0530 Subject: [PATCH 1/4] Added empty op val and non-empty flagName test --- check/test.go | 2 +- check/test_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/check/test.go b/check/test.go index 2aee9b0b0..99699e8ef 100644 --- a/check/test.go +++ b/check/test.go @@ -143,7 +143,7 @@ func (t flagTestItem) findValue(s string) (match bool, value string, err error) if strings.HasPrefix(t.Flag, "--") { value = "true" } else { - value = vals[1] + value = "" } } } else { diff --git a/check/test_test.go b/check/test_test.go index 29eb26922..be18e2aa8 100644 --- a/check/test_test.go +++ b/check/test_test.go @@ -600,6 +600,7 @@ func TestCompareOp(t *testing.T) { // Test Op "eq" {label: "op=eq, both empty", op: "eq", flagVal: "", compareValue: "", expectedResultPattern: "'' is equal to ''", testResult: true, flagName: ""}, + {label: "op=eq, both empty, flagName non empty", op: "eq", flagVal: "", compareValue: "", expectedResultPattern: "'' is equal to ''", testResult: true, flagName: "flagName"}, { label: "op=eq, true==true", op: "eq", flagVal: "true", From 41e8ecc9ba41f69b01b4b73d165e907d24074624 Mon Sep 17 00:00:00 2001 From: Arjun Khunti Date: Tue, 31 Oct 2023 16:26:56 +0530 Subject: [PATCH 2/4] Adding if-condition for eq operator and empty compare value --- check/test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/check/test.go b/check/test.go index 99699e8ef..d06efca7d 100644 --- a/check/test.go +++ b/check/test.go @@ -143,7 +143,11 @@ func (t flagTestItem) findValue(s string) (match bool, value string, err error) if strings.HasPrefix(t.Flag, "--") { value = "true" } else { - value = "" + if t.Compare.Op == "eq" { + value = "" + } else { + value = vals[1] + } } } } else { From 3ca0a6cc3add98c85024e2c6902358b2ae227e5b Mon Sep 17 00:00:00 2001 From: Arjun Khunti Date: Tue, 31 Oct 2023 16:49:40 +0530 Subject: [PATCH 3/4] Updated expectedResultPattern --- check/test_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check/test_test.go b/check/test_test.go index be18e2aa8..ffd93555d 100644 --- a/check/test_test.go +++ b/check/test_test.go @@ -600,7 +600,7 @@ func TestCompareOp(t *testing.T) { // Test Op "eq" {label: "op=eq, both empty", op: "eq", flagVal: "", compareValue: "", expectedResultPattern: "'' is equal to ''", testResult: true, flagName: ""}, - {label: "op=eq, both empty, flagName non empty", op: "eq", flagVal: "", compareValue: "", expectedResultPattern: "'' is equal to ''", testResult: true, flagName: "flagName"}, + {label: "op=eq, both empty, flagName non empty", op: "eq", flagVal: "", compareValue: "", expectedResultPattern: "'flagName' is equal to ''", testResult: true, flagName: "flagName"}, { label: "op=eq, true==true", op: "eq", flagVal: "true", From 4dc29bde29720ee15ded2d013236d7c976780566 Mon Sep 17 00:00:00 2001 From: Arjun Khunti Date: Tue, 7 Nov 2023 13:00:30 +0530 Subject: [PATCH 4/4] Fix root:root e2e tests --- check/test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check/test.go b/check/test.go index d06efca7d..8aad03d05 100644 --- a/check/test.go +++ b/check/test.go @@ -143,7 +143,7 @@ func (t flagTestItem) findValue(s string) (match bool, value string, err error) if strings.HasPrefix(t.Flag, "--") { value = "true" } else { - if t.Compare.Op == "eq" { + if t.Compare.Op == "eq" && !strings.Contains(t.Flag, ":") { value = "" } else { value = vals[1]