use `.zero?` instead of `== 0`
This commit is contained in:
parent
895e1b3ed1
commit
7ce0a61a99
|
@ -81,7 +81,7 @@ module Gitlab
|
||||||
|
|
||||||
def delete_test_file(tmp_path)
|
def delete_test_file(tmp_path)
|
||||||
_, status = exec_with_timeout(%W{ rm -f #{tmp_path} })
|
_, status = exec_with_timeout(%W{ rm -f #{tmp_path} })
|
||||||
status == 0
|
status.zero?
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
File.delete(tmp_path) rescue Errno::ENOENT
|
File.delete(tmp_path) rescue Errno::ENOENT
|
||||||
end
|
end
|
||||||
|
@ -90,7 +90,7 @@ module Gitlab
|
||||||
stat_path = File.join(storage_path(storage_name), '.')
|
stat_path = File.join(storage_path(storage_name), '.')
|
||||||
begin
|
begin
|
||||||
_, status = exec_with_timeout(%W{ stat #{stat_path} })
|
_, status = exec_with_timeout(%W{ stat #{stat_path} })
|
||||||
status == 0
|
status.zero?
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
File.exist?(stat_path) && File::Stat.new(stat_path).readable?
|
File.exist?(stat_path) && File::Stat.new(stat_path).readable?
|
||||||
end
|
end
|
||||||
|
@ -100,7 +100,7 @@ module Gitlab
|
||||||
_, status = exec_with_timeout(%W{ tee #{tmp_path} }) do |stdin|
|
_, status = exec_with_timeout(%W{ tee #{tmp_path} }) do |stdin|
|
||||||
stdin.write(RANDOM_STRING)
|
stdin.write(RANDOM_STRING)
|
||||||
end
|
end
|
||||||
status == 0
|
status.zero?
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
written_bytes = File.write(tmp_path, RANDOM_STRING) rescue Errno::ENOENT
|
written_bytes = File.write(tmp_path, RANDOM_STRING) rescue Errno::ENOENT
|
||||||
written_bytes == RANDOM_STRING.length
|
written_bytes == RANDOM_STRING.length
|
||||||
|
@ -110,7 +110,7 @@ module Gitlab
|
||||||
_, status = exec_with_timeout(%W{ diff #{tmp_path} - }) do |stdin|
|
_, status = exec_with_timeout(%W{ diff #{tmp_path} - }) do |stdin|
|
||||||
stdin.write(RANDOM_STRING)
|
stdin.write(RANDOM_STRING)
|
||||||
end
|
end
|
||||||
status == 0
|
status.zero?
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
file_contents = File.read(tmp_path) rescue Errno::ENOENT
|
file_contents = File.read(tmp_path) rescue Errno::ENOENT
|
||||||
file_contents == RANDOM_STRING
|
file_contents == RANDOM_STRING
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||||
describe Gitlab::HealthChecks::FsShardsCheck do
|
describe Gitlab::HealthChecks::FsShardsCheck do
|
||||||
def command_exists?(command)
|
def command_exists?(command)
|
||||||
_, status = Gitlab::Popen.popen(%W{ #{command} 1 echo })
|
_, status = Gitlab::Popen.popen(%W{ #{command} 1 echo })
|
||||||
status == 0
|
status.zero?
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue