Skip to content

Commit

Permalink
Merge pull request #41 from Kyorai/mk-reorganize-some-tests
Browse files Browse the repository at this point in the history
Re-arrange some tests
  • Loading branch information
michaelklishin authored Aug 2, 2024
2 parents 7623c62 + a50cd58 commit 65c1e02
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-module(cuttlefish_escript_test).
-module(cuttlefish_escript_tests).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-module(cuttlefish_integration_test).
-module(cuttlefish_integration_tests).

-include_lib("kernel/include/logger.hrl").
-include_lib("eunit/include/eunit.hrl").
Expand Down Expand Up @@ -45,21 +45,6 @@ breaks_on_fuzzy_and_strict_match_test() ->
?assertMatch({error, add_defaults, _}, cuttlefish_generator:map(Schema, Conf)),
ok.

breaks_on_rhs_not_found_test() ->
Schema = cuttlefish_schema:file("test/riak.schema"),
Conf = [{["ring", "state_dir"], "$(tyktorp)/ring"}],
?assertMatch({error, rhs_subs, _}, cuttlefish_generator:map(Schema, Conf)),
ok.

breaks_on_rhs_infinite_loop_test() ->
Schema = cuttlefish_schema:file("test/riak.schema"),
Conf = [
{["ring", "state_dir"], "$(platform_data_dir)/ring"},
{["platform_data_dir"], "$(ring.state_dir)/data"}
],
?assertMatch({error, rhs_subs, _}, cuttlefish_generator:map(Schema, Conf)),
ok.

breaks_on_bad_enum_test() ->
Schema = cuttlefish_schema:file("test/riak.schema"),
Conf = [{["storage_backend"], penguin}],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-module(cuttlefish_nested_schema_test).
-module(cuttlefish_nested_schema_tests).

-include_lib("eunit/include/eunit.hrl").

Expand Down
35 changes: 35 additions & 0 deletions test/cuttlefish_subs_integration_tests.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-module(cuttlefish_subs_integration_tests).

-include_lib("kernel/include/logger.hrl").
-include_lib("eunit/include/eunit.hrl").

basic_rhs_subs_1_test() ->
Schema = cuttlefish_schema:file("test/example1.schema"),
Conf = [
{["example1", "ab"], "ab-ab"},
{["example1", "cd"], "$(example1.ab)"}
],
Generated = cuttlefish_generator:map(Schema, Conf),
?assertEqual([
{example1, [
{cd, "ab-ab"},
{ab, "ab-ab"}
]}
], Generated),
ok.


breaks_on_rhs_not_found_test() ->
Schema = cuttlefish_schema:file("test/riak.schema"),
Conf = [{["ring", "state_dir"], "$(tyktorp)/ring"}],
?assertMatch({error, rhs_subs, _}, cuttlefish_generator:map(Schema, Conf)),
ok.

breaks_on_rhs_infinite_loop_test() ->
Schema = cuttlefish_schema:file("test/riak.schema"),
Conf = [
{["ring", "state_dir"], "$(platform_data_dir)/ring"},
{["platform_data_dir"], "$(ring.state_dir)/data"}
],
?assertMatch({error, rhs_subs, _}, cuttlefish_generator:map(Schema, Conf)),
ok.
7 changes: 7 additions & 0 deletions test/example1.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{mapping, "example1.ab", "example1.ab", [
{datatype, [string]}
]}.

{mapping, "example1.cd", "example1.cd", [
{datatype, [string]}
]}.

0 comments on commit 65c1e02

Please sign in to comment.