Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added empty actual value and expected value and non-empty flagName test #1517

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion check/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = vals[1]
if t.Compare.Op == "eq" && !strings.Contains(t.Flag, ":") {
Copy link
Collaborator

@mozillazg mozillazg Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, adding a workaround code (!strings.Contains(t.Flag, ":")) is not a good idea.

How about adding a new op like isempty instead of changing the eq op for your cases to support empty value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the process of adding a new operation, and I'm thinking about closing this pull request. I'll communicate this process in the corresponding issue to encourage others to contribute instead.

value = ""
} else {
value = vals[1]
}
}
}
} else {
Expand Down
1 change: 1 addition & 0 deletions check/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "'flagName' is equal to ''", testResult: true, flagName: "flagName"},

{
label: "op=eq, true==true", op: "eq", flagVal: "true",
Expand Down
Loading