Skip to content

Commit

Permalink
Added tests for dictionary, separatorTokens and nonSeparatorTokens se…
Browse files Browse the repository at this point in the history
…ttings.
  • Loading branch information
mumez committed Oct 7, 2023
1 parent c5d93b5 commit 63f9b1e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions-index-settings
setDictionary: keys
^ self applySettingsUsing: [ :opts |
opts dictionary: keys ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions-index-settings
setNonSeparatorTokens: nonSeparatorTokens
^ self applySettingsUsing: [ :opts |
opts nonSeparatorTokens: nonSeparatorTokens ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions-index-settings
setSeparatorTokens: separatorTokens
^ self applySettingsUsing: [ :opts |
opts separatorTokens: separatorTokens ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
tests
testSetGetIndexDictionarySettings
| originalIndexes newIndexId index settingsTask createIndexTask appliedSettings deleteIndexTask |
originalIndexes := meilisearch indexes.
newIndexId := 'mailisearch-st-test-index-dictionary-settings'.
createIndexTask := meilisearch createIndex: newIndexId.
createIndexTask waitEndedForAWhile.
self assert: createIndexTask isSucceeded.

index := (meilisearch index: newIndexId).
settingsTask := index applySettingsUsing: [ :opts |
opts dictionary: #('J. R. R.' 'J.R.R.').
].
settingsTask waitEndedForAWhile.

appliedSettings := index getAllSettings.

self assert: appliedSettings dictionary asSortedCollection equals: #('J. R. R.' 'J.R.R.') asSortedCollection.

(index setDictionary: #('1')) waitEndedForAWhile.

appliedSettings := index getAllSettings.

self assert: appliedSettings dictionary asSortedCollection equals: #('1') asSortedCollection.

deleteIndexTask := index delete.
deleteIndexTask waitEndedForAWhile.
self assert: deleteIndexTask isSucceeded.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tests
testSetGetIndexSeparatorTokensSettings
| originalIndexes newIndexId index settingsTask createIndexTask appliedSettings deleteIndexTask |
originalIndexes := meilisearch indexes.
newIndexId := 'mailisearch-st-test-index-separator-tokens-settings'.
createIndexTask := meilisearch createIndex: newIndexId.
createIndexTask waitEndedForAWhile.
self assert: createIndexTask isSucceeded.

index := (meilisearch index: newIndexId).
settingsTask := index applySettingsUsing: [ :opts |
opts separatorTokens: #('|' '…'); nonSeparatorTokens: #('@' '#' '&').
].
settingsTask waitEndedForAWhile.

appliedSettings := index getAllSettings.

self assert: appliedSettings separatorTokens asSortedCollection equals: #('|' '…') asSortedCollection.
self assert: appliedSettings nonSeparatorTokens asSortedCollection equals: #('@' '#' '&') asSortedCollection.

(index setSeparatorTokens: #('1')) waitEndedForAWhile.
(index setNonSeparatorTokens: #('2')) waitEndedForAWhile.

appliedSettings := index getAllSettings.

self assert: appliedSettings separatorTokens asSortedCollection equals: #('1') asSortedCollection.
self assert: appliedSettings nonSeparatorTokens asSortedCollection equals: #('2') asSortedCollection.

deleteIndexTask := index delete.
deleteIndexTask waitEndedForAWhile.
self assert: deleteIndexTask isSucceeded.

0 comments on commit 63f9b1e

Please sign in to comment.