Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add tests for (and fix) drink searches

  • Loading branch information...
commit 79f91a0bf70822c61dcb85e2ee8132f0698aaa71 1 parent c2219f3
@frioux authored
Showing with 38 additions and 4 deletions.
  1. +8 −4 lib/DU/App/Command/drink/ls.pm
  2. +30 −0 t/integration/app/drink.t
View
12 lib/DU/App/Command/drink/ls.pm
@@ -33,10 +33,14 @@ sub execute {
$rs = $rs->cli_find('*' . $opt->easy_search_by_name . '*')
if $opt->easy_search_by_name;
- $rs = $rs->some($user) if $opt->some_ingredients;
- $rs = $rs->none($user) if $opt->no_ingredients;
- $rs = $rs->every($user) if $opt->all_ingredients;
- $rs = $rs->nearly($user, $opt->nearly_all_ingredients ) if $opt->nearly_all_ingredients;
+ $rs = $rs->some_by_user_inventory($user) if $opt->some_ingredients;
+
+ $rs = $rs->none_by_user_inventory($user) if $opt->no_ingredients;
+
+ $rs = $rs->every_by_user($user) if $opt->all_ingredients;
+
+ $rs = $rs->nearly_by_user($user, $opt->nearly_all_ingredients )
+ if $opt->nearly_all_ingredients;
say '* ' . $_->name for $rs->all
}
View
30 t/integration/app/drink.t
@@ -39,6 +39,36 @@ subtest 'ls' => sub {
'* Cuba Libre',
'* Frewba Libre',
]);
+
+ $result = test_app($app => [qw(drink ls -G lib)]);
+ stdout_is($result, [
+ '* Cuba Libre',
+ '* Frewba Libre',
+ ]);
+
+ $result = test_app($app => [qw(drink ls -g), '??ba libre']);
+ stdout_is($result, [
+ '* Cuba Libre',
+ ]);
+
+ $result = test_app($app => [qw(drink ls -s)]);
+ stdout_is($result, [
+ '* Tom Collins',
+ ]);
+
+ $result = test_app($app => [qw(drink ls -n)]);
+ stdout_is($result, [
+ '* Cuba Libre',
+ '* Frewba Libre',
+ ]);
+
+ $result = test_app($app => [qw(drink ls -a)]);
+ stdout_is($result, []);
+
+ $result = test_app($app => [qw(drink ls -e 1)]);
+ stdout_is($result, [
+ '* Tom Collins',
+ ]);
};
subtest 'new' => sub {
Please sign in to comment.
Something went wrong with that request. Please try again.