2020-01-12 18:12:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative "shared_context_for_backup_restore"
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe BackupRestore::BackupFileHandler do
|
2022-07-27 12:14:14 -04:00
|
|
|
include_context "with shared stuff"
|
2020-01-12 18:12:27 -05:00
|
|
|
|
|
|
|
it "works with current backup file format" do
|
|
|
|
expect_decompress_and_clean_up_to_work(
|
|
|
|
backup_filename: "backup_since_v1.6.tar.gz",
|
|
|
|
require_metadata_file: false,
|
|
|
|
require_uploads: true,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works with SQL only backup file" do
|
|
|
|
expect_decompress_and_clean_up_to_work(
|
|
|
|
backup_filename: "sql_only_backup.sql.gz",
|
|
|
|
expected_dump_filename: "sql_only_backup.sql",
|
|
|
|
require_metadata_file: false,
|
|
|
|
require_uploads: false,
|
|
|
|
)
|
|
|
|
end
|
2020-08-21 09:09:50 -04:00
|
|
|
|
|
|
|
it "works with backup file which uses wrong upload path" do
|
|
|
|
expect_decompress_and_clean_up_to_work(
|
|
|
|
backup_filename: "backup_with_wrong_upload_path.tar.gz",
|
|
|
|
require_metadata_file: false,
|
|
|
|
require_uploads: true,
|
|
|
|
expected_upload_paths: %w[
|
|
|
|
uploads/default/original/1X/both.txt
|
|
|
|
uploads/default/original/1X/only-uploads.txt
|
|
|
|
uploads/default/original/1X/only-var.txt
|
|
|
|
],
|
|
|
|
) do |upload_path|
|
|
|
|
content = File.read(upload_path).chomp
|
|
|
|
|
|
|
|
case File.basename(upload_path)
|
|
|
|
when "both.txt", "only-var.txt"
|
|
|
|
expect(content).to eq("var")
|
|
|
|
when "only-uploads.txt"
|
|
|
|
expect(content).to eq("uploads")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-02-09 10:02:44 -05:00
|
|
|
|
|
|
|
it "allows overriding the backup store" do
|
|
|
|
SiteSetting.s3_backup_bucket = "s3-backup-bucket"
|
|
|
|
SiteSetting.s3_access_key_id = "s3-access-key-id"
|
|
|
|
SiteSetting.s3_secret_access_key = "s3-secret-access-key"
|
|
|
|
SiteSetting.backup_location = BackupLocationSiteSetting::S3
|
|
|
|
|
|
|
|
expect_decompress_and_clean_up_to_work(
|
|
|
|
backup_filename: "backup_since_v1.6.tar.gz",
|
|
|
|
require_metadata_file: false,
|
|
|
|
require_uploads: true,
|
|
|
|
location: BackupLocationSiteSetting::LOCAL,
|
|
|
|
)
|
|
|
|
end
|
2020-01-12 18:12:27 -05:00
|
|
|
end
|