Skip to content

Conversation

@kostyanf14
Copy link
Contributor

No description provided.

Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Copy link
Contributor

@akihikodaki akihikodaki left a comment

Choose a reason for hiding this comment

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

Assuming the only difference between listtestresults and listallresults is that the presence of $target, I think it's better to handle the case that $target is not specified for listtestresults instead of adding a completely new function.

@kostyanf14
Copy link
Contributor Author

kostyanf14 commented Mar 27, 2025

Assuming the only difference between listtestresults and listallresults is that the presence of $target, I think it's better to handle the case that $target is not specified for listtestresults instead of adding a completely new function.

This will break backward compatibility because test_id will be a named parameter. Or if we allow test_id = '' this will break the current behavior of raising the error when test_id was absent.

Also listtestresults and listallresults has one more difference: listtestresults return object, listallresults returns array of objects

@akihikodaki
Copy link
Contributor

Assuming the only difference between listtestresults and listallresults is that the presence of $target, I think it's better to handle the case that $target is not specified for listtestresults instead of adding a completely new function.

This will break backward compatibility because test_id will be a named parameter. Or if we allow test_id = '' this will break the current behavior of raising the error when test_id was absent.

It seems positional parameters can still be explicitly named: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.5

So the following command should work:

listtestresults -target <targetkey> -project <projectname> -machine <testmachine> -pool <poolname>

However, it will lead to the following statement:

throw "Please provide a test's id."

We can implement a logic to handle the case where the test ID is missing here.

@YanVugenfirer
Copy link
Contributor

I suggest not to increase a complexity for the future developers. Better have additional function. Return list of lists is also different from returning a list.

@akihikodaki
Copy link
Contributor

I expect explicitly naming parameters results in better readability than having an additional function.

It is not clear how listallresults and listtestresults are different; listallresults still does not list literally all results but lists results of tests filtered with tagetkey, projectname, testmachine, and poolname. listallresults also "lists test results" so listtestresults does not differentiate from that function too. It will be clear that the testid parameter is missing if we explicitly name parameters.

Both functions return an array of objects.

@kostyanf14
Copy link
Contributor Author

@akihikodaki

What about deduplicate code but still have 2 functions the first with test_id, and the second without?

@akihikodaki
Copy link
Contributor

@akihikodaki

What about deduplicate code but still have 2 functions the first with test_id, and the second without?

The code duplication is problematic, but I also see one function with optionally named parameters is better as an interface design than two similar functions due to the reason described in: #63 (comment)

Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
@kostyanf14 kostyanf14 requested a review from akihikodaki March 31, 2025 16:36
@kostyanf14 kostyanf14 force-pushed the all-result branch 2 times, most recently from d265d73 to 2905787 Compare March 31, 2025 16:38
In this case, all results will be listed.

Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
@YanVugenfirer YanVugenfirer merged commit 4768d30 into master Apr 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants