diff options
author | Rémy Coutable <remy@rymai.me> | 2017-12-13 20:28:04 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-12-13 20:28:04 +0300 |
commit | 4fe92b1de16469e0f8534d7c85d3e8b5c868b558 (patch) | |
tree | 75e42f706b6c5a0a926b08822b19ee7de0b447a1 /spec | |
parent | 013e681625ada14ba977c5a66ab104924a9fdce6 (diff) | |
parent | ab4fa64308176cc069e6a731d35a53c886af805e (diff) |
Merge branch 'add-tcp-check-rake-task' into 'master'
Add a gitlab:tcp_check rake task
See merge request gitlab-org/gitlab-ce!15759
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/tcp_checker_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/tcp_checker_spec.rb b/spec/lib/gitlab/tcp_checker_spec.rb new file mode 100644 index 00000000000..4acf0334496 --- /dev/null +++ b/spec/lib/gitlab/tcp_checker_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Gitlab::TcpChecker do + before do + @server = TCPServer.new('localhost', 0) + _, @port, _, @ip = @server.addr + end + + after do + @server.close + end + + subject(:checker) { described_class.new(@ip, @port) } + + describe '#check' do + subject { checker.check } + + it 'can connect to an open port' do + is_expected.to be_truthy + + expect(checker.error).to be_nil + end + + it 'fails to connect to a closed port' do + @server.close + + is_expected.to be_falsy + + expect(checker.error).to be_a(Errno::ECONNREFUSED) + end + end +end |