Skip to content

Commit

Permalink
test: added unit tests fot negative nutriments (#8044)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbenben2 authored Jan 30, 2023
1 parent dd6bb80 commit d2c0a8b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/dataqualityfood.t
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,28 @@ ok(
'energy not matching nutrient'
) or diag explain $product_ref;

# en:nutrition-value-negative-$nid should be raised - for nutriments (except nutriments containing "nutrition-score") below 0
$product_ref = {
nutriments => {
"proteins_100g" => -1,
}
};
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:nutrition-value-negative-proteins',
'nutriment should have positive value (except nutrition-score)', 1
);

# en:nutrition-value-negative-$nid should NOT be raised - for nutriments containing "nutrition-score" and below 0
$product_ref = {
nutriments => {
"nutrition-score-fr_100g" => -1,
}
};
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:nutrition-value-negative-nutrition-score-fr',
'nutriment should have positive value (except nutrition-score)', 0
);

done_testing();

0 comments on commit d2c0a8b

Please sign in to comment.