-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand the capabilities of dictionaries (#75)
* Expand the capabilities of dictionaries * Added config option 'default_dictionary' for use any custom dictionary * Added config option 'additional_dictionaries' for expand exist dictionary * Refactoring of generate_dictionary/1 and concat_dictionaries/2
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fabuloso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wikipedia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
-module(sheldon_dictionaries_SUITE). | ||
|
||
-behaviour(ct_suite). | ||
|
||
-export([all/0, init_per_suite/1, end_per_suite/1, init_per_testcase/2, | ||
end_per_testcase/2]). | ||
-export([default_dictionary/1, additional_dictionary/1]). | ||
|
||
%% ============================================================================= | ||
%% Common test | ||
%% ============================================================================= | ||
|
||
-spec all() -> [atom()]. | ||
all() -> | ||
[default_dictionary, additional_dictionary]. | ||
|
||
-spec init_per_suite(ct_suite:ct_config()) -> ct_suite:ct_config(). | ||
init_per_suite(Config) -> | ||
Dictionary = [code:priv_dir(sheldon), "/../test/dictionaries/default_dictionary.txt"], | ||
ok = application:set_env(sheldon, default_dictionary, Dictionary), | ||
Config. | ||
|
||
-spec end_per_suite(ct_suite:ct_config()) -> ct_suite:ct_config(). | ||
end_per_suite(Config) -> | ||
Config. | ||
|
||
-spec init_per_testcase(ct_suite:ct_testname(), ct_suite:ct_config()) -> | ||
ct_suite:ct_config() | {fail, term()} | {skip, term()}. | ||
init_per_testcase(default_dictionary, Config) -> | ||
ok = sheldon:start(), | ||
Config; | ||
init_per_testcase(additional_dictionary, Config) -> | ||
One = [code:priv_dir(sheldon), "/../test/dictionaries/additional_dictionary_1.txt"], | ||
Two = [code:priv_dir(sheldon), "/../test/dictionaries/additional_dictionary_2.txt"], | ||
ok = application:set_env(sheldon, additional_dictionaries, [One, Two]), | ||
ok = sheldon:start(), | ||
Config; | ||
init_per_testcase(_Name, Config) -> | ||
Config. | ||
|
||
-spec end_per_testcase(ct_suite:ct_testname(), ct_suite:ct_config()) -> | ||
term() | {fail, term()} | {save_config, ct_suite:ct_config()}. | ||
end_per_testcase(_Name, _Config) -> | ||
ok = application:stop(sheldon), | ||
ok. | ||
|
||
%% ============================================================================= | ||
%% Test Cases | ||
%% ============================================================================= | ||
|
||
-spec default_dictionary(ct_suite:ct_config()) -> ok | no_return(). | ||
default_dictionary(_Config) -> | ||
ok = sheldon:check("wikipedia"), | ||
#{bazinga := _} = sheldon:check("wiki"), | ||
ok. | ||
|
||
-spec additional_dictionary(ct_suite:ct_config()) -> ok | no_return(). | ||
additional_dictionary(_Config) -> | ||
ok = sheldon:check("Wikipedia"), | ||
ok = sheldon:check("Wiki"), | ||
ok = sheldon:check("Fabuloso"), | ||
ok. |