Skip to content

Commit

Permalink
Add migration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Nov 17, 2023
1 parent 82d21e5 commit 1ab7ce1
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions lib/tasks/tests.rake
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ namespace :tests do
puts 'Default posting language not migrated as expected for kmr users'
exit(1)
end

unless Account.find_by(username: 'suspended', domain: nil).suspended?
puts 'Unexpected value for Account#suspended? for user @suspended'
exit(1)
end

if Account.find_by(username: 'deleted', domain: nil).suspended?
puts 'Unexpected value for Account#suspended? for user @deleted'
exit(1)
end

unless Account.find_by(username: 'deleted', domain: nil).deleted?
puts 'Unexpected value for Account#deleted? for user @deleted'
exit(1)
end
end

desc 'Populate the database with test data for 2.4.3'
Expand Down Expand Up @@ -142,17 +157,17 @@ namespace :tests do
INSERT INTO "accounts"
(id, username, domain, private_key, public_key, created_at, updated_at)
VALUES
(10, 'kmruser', NULL, #{user_private_key}, #{user_public_key}, now(), now());
(12, 'kmruser', NULL, #{user_private_key}, #{user_public_key}, now(), now());
INSERT INTO "users"
(id, account_id, email, created_at, updated_at, admin, locale, chosen_languages)
VALUES
(4, 10, 'kmruser@localhost', now(), now(), false, 'ku', '{en,kmr,ku,ckb}');
(5, 12, 'kmruser@localhost', now(), now(), false, 'ku', '{en,kmr,ku,ckb}');
INSERT INTO "settings"
(id, thing_type, thing_id, var, value, created_at, updated_at)
VALUES
(5, 'User', 4, 'default_language', E'--- kmr\n', now(), now());
(5, 'User', 5, 'default_language', E'--- kmr\n', now(), now());
SQL
end

Expand Down Expand Up @@ -221,18 +236,25 @@ namespace :tests do
1, 'https://activitypub.com/users/evil/inbox', 'https://activitypub.com/users/evil/outbox',
'https://activitypub.com/users/evil/followers', true);
INSERT INTO "accounts"
(id, username, domain, private_key, public_key, created_at, updated_at, suspended)
VALUES
(10, 'suspended', NULL, #{admin_private_key}, #{admin_public_key}, now(), now(), true),
(11, 'deleted', NULL, #{user_private_key}, #{user_public_key}, now(), now(), true);
-- users
INSERT INTO "users"
(id, account_id, email, created_at, updated_at, admin)
VALUES
(1, 1, 'admin@localhost', now(), now(), true),
(2, 2, 'user@localhost', now(), now(), false);
(2, 2, 'user@localhost', now(), now(), false),
(3, 10, 'suspended@localhost', now(), now(), false);
INSERT INTO "users"
(id, account_id, email, created_at, updated_at, admin, locale)
VALUES
(3, 8, 'ptuser@localhost', now(), now(), false, 'pt');
(4, 8, 'ptuser@localhost', now(), now(), false, 'pt');
-- conversations
INSERT INTO "conversations" (id, created_at, updated_at) VALUES (1, now(), now());
Expand Down

0 comments on commit 1ab7ce1

Please sign in to comment.