summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2018-03-13 11:32:30 +0100
committerJacob Vosmaer <jacob@gitlab.com>2018-03-13 11:32:42 +0100
commit56b6b8c4fb144b9b79d60dd883b541e08b8c75c2 (patch)
treef562d7d23196a9f9a86c8416934a991fff11d690
parent77524085f5d4fe3e174589499a038d5bb42ea364 (diff)
downloadgitlab-shell-56b6b8c4fb144b9b79d60dd883b541e08b8c75c2.tar.gz
Fix tests that fail locally
-rw-r--r--spec/gitlab_custom_hook_spec.rb2
-rw-r--r--spec/gitlab_shell_authorized_keys_check_spec.rb26
-rw-r--r--spec/httpunix_spec.rb2
3 files changed, 17 insertions, 13 deletions
diff --git a/spec/gitlab_custom_hook_spec.rb b/spec/gitlab_custom_hook_spec.rb
index 540cd2b..f9cd6ac 100644
--- a/spec/gitlab_custom_hook_spec.rb
+++ b/spec/gitlab_custom_hook_spec.rb
@@ -56,7 +56,7 @@ describe GitlabCustomHook do
FileUtils.rm_rf(File.join(tmp_repo_path))
FileUtils.rm_rf(File.join(global_custom_hooks_path))
FileUtils.rm_rf(File.join(tmp_root_path, 'hooks'))
- FileUtils.rm_f(File.join(tmp_root_path, 'config.yml'))
+ FileUtils.rm_f(p(File.join(tmp_root_path, 'config.yml')))
end
def expect_call_receive_hook(path)
diff --git a/spec/gitlab_shell_authorized_keys_check_spec.rb b/spec/gitlab_shell_authorized_keys_check_spec.rb
index 166e675..fb1af6a 100644
--- a/spec/gitlab_shell_authorized_keys_check_spec.rb
+++ b/spec/gitlab_shell_authorized_keys_check_spec.rb
@@ -1,21 +1,20 @@
require_relative 'spec_helper'
describe 'bin/gitlab-shell-authorized-keys-check' do
- def config_path
- File.join(ROOT_PATH, 'config.yml')
- end
+ let(:original_root_path) { ROOT_PATH }
+ let(:tmp_root_path) { File.join(original_root_path, 'tmp') }
- def tmp_config_path
- config_path + ".#{$$}"
+ def config_path
+ File.join(tmp_root_path, 'config.yml')
end
def tmp_socket_path
- File.join(ROOT_PATH, 'tmp', 'gitlab-shell-authorized-keys-check-socket')
+ 'tmp/gitlab-shell-authorized-keys-check-socket'
end
before(:all) do
FileUtils.mkdir_p(File.dirname(tmp_socket_path))
- FileUtils.touch(File.join(ROOT_PATH, '.gitlab_shell_secret'))
+ FileUtils.touch(File.join(tmp_root_path, '.gitlab_shell_secret'))
@server = HTTPUNIXServer.new(BindAddress: tmp_socket_path)
@server.mount_proc('/api/v4/internal/authorized_keys') do |req, res|
@@ -33,21 +32,26 @@ describe 'bin/gitlab-shell-authorized-keys-check' do
sleep(0.1) while @webrick_thread.alive? && @server.status != :Running
raise "Couldn't start stub GitlabNet server" unless @server.status == :Running
- FileUtils.mv(config_path, tmp_config_path) if File.exist?(config_path)
File.open(config_path, 'w') do |f|
f.write("---\ngitlab_url: http+unix://#{CGI.escape(tmp_socket_path)}\n")
end
+
+ FileUtils.rm_rf([File.join(tmp_root_path, 'bin'), File.join(tmp_root_path, 'lib')])
+ FileUtils.cp_r(['bin', 'lib'], tmp_root_path)
end
after(:all) do
@server.shutdown if @server
@webrick_thread.join if @webrick_thread
FileUtils.rm_f(config_path)
- FileUtils.mv(tmp_config_path, config_path) if File.exist?(tmp_config_path)
end
- let(:gitlab_shell_path) { File.join(ROOT_PATH, 'bin', 'gitlab-shell') }
- let(:authorized_keys_check_path) { File.join(ROOT_PATH, 'bin', 'gitlab-shell-authorized-keys-check') }
+ before do
+ stub_const('ROOT_PATH', tmp_root_path)
+ end
+
+ let(:gitlab_shell_path) { File.join(tmp_root_path, 'bin', 'gitlab-shell') }
+ let(:authorized_keys_check_path) { File.join(tmp_root_path, 'bin', 'gitlab-shell-authorized-keys-check') }
it 'succeeds when a valid key is given' do
output, status = run!
diff --git a/spec/httpunix_spec.rb b/spec/httpunix_spec.rb
index 4c59340..c9b618d 100644
--- a/spec/httpunix_spec.rb
+++ b/spec/httpunix_spec.rb
@@ -15,7 +15,7 @@ end
describe Net::HTTPUNIX do
def tmp_socket_path
- File.join(ROOT_PATH, 'tmp/test-socket')
+ 'tmp/test-socket'
end
before(:all) do