Skip to content

Commit

Permalink
Add feature specs for migration parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyates committed Jun 30, 2023
1 parent 3da5a46 commit 62acb85
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions spec/features/migrate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,62 @@
messages = test_server.folder_messages(folder)
expect(messages[0]["FLAGS"]).to include(:Draft)
end

context "when migrating from a subfolder" do
let(:source_folder) { "my_sub.my_folder" }
let(:setup) do
create_config(**config_options)
append_local(email: email, folder: source_folder, subject: "Hi")
end

it "copies email from subfolders on the source account" do
command = [
"imap-backup",
"migrate",
email,
destination_account[:username],
"--source-prefix=my_sub",
"--source-delimiter=."
].join(" ")

run_command_and_stop command

messages = test_server.folder_messages(folder)
expected = <<~MESSAGE.gsub("\n", "\r\n")
From: sender@example.com
Subject: Hi
body
MESSAGE
expect(messages[0]["BODY[]"]).to eq(expected)
end
end

context "when migrating into a subfolder" do
let(:destination_folder) { "my_sub.my_folder" }

it "copies email to subfolders on the destination account" do
command = [
"imap-backup",
"migrate",
email,
destination_account[:username],
"--destination-prefix=my_sub",
"--destination-delimiter=."
].join(" ")

run_command_and_stop command

messages = test_server.folder_messages(destination_folder)
expected = <<~MESSAGE.gsub("\n", "\r\n")
From: sender@example.com
Subject: Ciao
body
MESSAGE
expect(messages[0]["BODY[]"]).to eq(expected)
end
end
end

0 comments on commit 62acb85

Please sign in to comment.