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

test: Lang field read only #894

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
51 changes: 51 additions & 0 deletions test/api_add_product_main_language.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'dart:math';

import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:test/test.dart';

import 'test_constants.dart';

void main() {
OpenFoodAPIConfiguration.userAgent = TestConstants.TEST_USER_AGENT;
const UriProductHelper uriHelper = uriHelperFoodTest;

group('$OpenFoodAPIClient Save product main language', () {
String barcode_1 = '3017620425035';

test('Save product main language', () async {
ProductResultV3 result =
await OpenFoodAPIClient.getProductV3(ProductQueryConfiguration(
barcode_1,
version: ProductQueryVersion.v3,
));

Product? product = result.product;

expect(product, isNotNull);

print('Start lang: ${product!.lang}');

product.lang = OpenFoodFactsLanguage.GERMAN;

await OpenFoodAPIClient.saveProduct(
TestConstants.TEST_USER,
product,
uriHelper: uriHelper,
);

ProductResultV3 result_1 =
await OpenFoodAPIClient.getProductV3(ProductQueryConfiguration(
barcode_1,
version: ProductQueryVersion.v3,
));

Product? product_1 = result_1.product;

expect(product_1, isNotNull);

print('End lang: ${product_1!.lang}');

expect(product_1.lang, OpenFoodFactsLanguage.GERMAN);
});
});
}