Skip to content
代码片段 群组 项目
提交 c6a96bc5 编辑于 作者: Gabriel Mazetto's avatar Gabriel Mazetto
浏览文件

Allow running backup against the test environment

上级 53a3b5f3
No related branches found
No related tags found
1 合并请求!2419Fix TanukiBot spec relying on outdated code
......@@ -71,6 +71,11 @@ def upload_path
# TODO: Use configuration solver
File.join(Gitlab.config.uploads.storage_path, 'uploads')
end
def env
@env ||= ActiveSupport::EnvironmentInquirer.new(
ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development")
end
end
end
end
......
......@@ -24,6 +24,9 @@ def initialize(context:, options:)
def backup!(backup_path, backup_id)
backup_output = backup_path.join(destination_path)
# During test, we ensure storage exists so we can run against `RAILS_ENV=test` environment
FileUtils.mkdir_p(storage_path) if context.env.test? && respond_to?(:storage_path, true)
target.dump(backup_output, backup_id)
end
......
# frozen_string_literal: true
FakeContext = Struct.new(:gitlab_version, :backup_basedir, keyword_init: true)
FakeContext = Struct.new(:gitlab_version, :backup_basedir, :env, keyword_init: true)
def spec_path
Pathname.new(__dir__).join('..').expand_path
......@@ -15,5 +15,9 @@ def stub_env(var, return_value)
end
def build_fake_context
FakeContext.new(gitlab_version: '16.10', backup_basedir: temp_path.join('backups'))
FakeContext.new(
gitlab_version: '16.10',
backup_basedir: temp_path.join('backups'),
env: ActiveSupport::EnvironmentInquirer.new('test')
)
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册