algolia / cli

🔍 Algolia’s official CLI devtool
https://www.algolia.com/doc/tools/cli
MIT License
101 stars 26 forks source link

fix: import of rules and synonyms #118

Closed Nagriar closed 1 year ago

Nagriar commented 1 year ago

Summary

This PR contains 2 fixes:

Clear rules/synoyms when empty batch is provided with clear existing

When the input is empty no batches are sent which led to keeping the existing rules/synonyms. The expected behaviour is to clear the existing rules/synonyms. Since the API rejected empty batches, the clear endpoint is required for this specific case.

Disable clear existing after the first batch

If the input contains more than 1000 items, the cli splits the input into several batches but if the flag ClearExistingRules/ReplaceExistingSynonyms is provided, only the last batch will be kept. This PR set the flag only for the first batch.

Test strategy

unit tests has been added to test both fixes