Skip to content

Commit

Permalink
#6 implement negative test
Browse files Browse the repository at this point in the history
  • Loading branch information
bearmug committed Feb 2, 2019
1 parent 3043129 commit a8dccda
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/epgsql_migrations_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,19 @@ incremental_migration_test(Opts) ->
{ok, _,[{<<"1">>}]},
epgsql:squery(Conn, "select count(*) from fruit where color = 'yellow'")).

wrong_initial_version_test(_Opts) -> ok.
wrong_initial_version_test(Opts) ->
Conn = ?config(conn, Opts),
PreparedCall = engine:migrate(
filename:join([?config(data_dir, Opts), "02-wrong-initial-version"]),
fun(F) ->
epgsql:with_transaction(Conn, fun(_) -> F() end)
end,
epgsql_query_fun(Conn)
),
?assertEqual(
{rollback, {badmatch, {error, unexpected_version, {expected, 0, supplied, 20}}}},
PreparedCall()).

migration_gap_test(_Opts) -> ok.
transactional_migration_test(_Opts) -> ok.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE fruit (
id SERIAL,
name TEXT NOT NULL
);
INSERT INTO fruit (name) VALUES (
'apple'
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE fruit (
id SERIAL,
name TEXT NOT NULL
);
INSERT INTO fruit (name) VALUES (
'apple'
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE fruit
ADD COLUMN color TEXT NOT NULL DEFAULT 'green';
INSERT INTO fruit (name, color) VALUES (
'lemon', 'yellow'
);

0 comments on commit a8dccda

Please sign in to comment.