fix(test): stub all migrations in migration_engine join-wait. Refs EventHub/EventHubBack#42
This commit is contained in:
@@ -3,6 +3,14 @@
|
||||
-include("records.hrl").
|
||||
|
||||
-define(LOCK_VERSION, "__migration_lock__").
|
||||
%% Keep in sync with migration_engine:?ALL_MIGRATIONS (atom → string version).
|
||||
-define(ALL_VERSIONS, [
|
||||
"20260501120000_base_schema",
|
||||
"20260504150000_test_migration",
|
||||
"20260716230000_ticket_source_and_hash_index",
|
||||
"20260717180000_stats_counters",
|
||||
"20260717190000_admin_stats_indexes"
|
||||
]).
|
||||
|
||||
setup() ->
|
||||
mnesia:stop(),
|
||||
@@ -37,9 +45,9 @@ test_ensure_applied() ->
|
||||
Status = migration_engine:status(),
|
||||
?assertEqual([], maps:get(pending, Status)),
|
||||
Applied = maps:get(applied, Status),
|
||||
?assert(lists:member("20260501120000_base_schema", Applied)),
|
||||
?assert(lists:member("20260504150000_test_migration", Applied)),
|
||||
?assert(lists:member("20260716230000_ticket_source_and_hash_index", Applied)).
|
||||
lists:foreach(fun(V) ->
|
||||
?assert(lists:member(V, Applied))
|
||||
end, ?ALL_VERSIONS).
|
||||
|
||||
test_ensure_applied_idempotent() ->
|
||||
?assertEqual(ok, migration_engine:ensure_applied()),
|
||||
@@ -55,12 +63,9 @@ test_join_wait() ->
|
||||
mnesia:dirty_write(#schema_migration{version = ?LOCK_VERSION, applied_at = Now}),
|
||||
spawn(fun() ->
|
||||
timer:sleep(100),
|
||||
mnesia:dirty_write(#schema_migration{
|
||||
version = "20260501120000_base_schema", applied_at = Now}),
|
||||
mnesia:dirty_write(#schema_migration{
|
||||
version = "20260504150000_test_migration", applied_at = Now}),
|
||||
mnesia:dirty_write(#schema_migration{
|
||||
version = "20260716230000_ticket_source_and_hash_index", applied_at = Now}),
|
||||
lists:foreach(fun(V) ->
|
||||
mnesia:dirty_write(#schema_migration{version = V, applied_at = Now})
|
||||
end, ?ALL_VERSIONS),
|
||||
mnesia:dirty_delete({schema_migration, ?LOCK_VERSION})
|
||||
end),
|
||||
?assertEqual(ok, migration_engine:ensure_applied()).
|
||||
|
||||
Reference in New Issue
Block a user