mirror of
https://github.com/puppetlabs/vmpooler-provider-vsphere.git
synced 2026-01-26 03:18:41 -05:00
(maint) Update spec tests for timeout change.
This commit is contained in:
parent
5e1891b990
commit
0fb77b917d
1 changed files with 7 additions and 7 deletions
|
|
@ -1399,44 +1399,44 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'opens socket with defaults' do
|
it 'opens socket with defaults' do
|
||||||
expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket)
|
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 5}).and_return(socket)
|
||||||
|
|
||||||
expect(subject.open_socket(hostname)).to eq(nil)
|
expect(subject.open_socket(hostname)).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'yields the socket if a block is given' do
|
it 'yields the socket if a block is given' do
|
||||||
expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket)
|
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: nil}).and_return(socket)
|
||||||
|
|
||||||
expect{ |socket| subject.open_socket(hostname,nil,nil,default_socket,&socket) }.to yield_control.exactly(1).times
|
expect{ |socket| subject.open_socket(hostname,nil,nil,default_socket,&socket) }.to yield_control.exactly(1).times
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'closes the opened socket' do
|
it 'closes the opened socket' do
|
||||||
expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket)
|
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 5}).and_return(socket)
|
||||||
expect(socket).to receive(:close)
|
expect(socket).to receive(:close)
|
||||||
|
|
||||||
expect(subject.open_socket(hostname)).to eq(nil)
|
expect(subject.open_socket(hostname)).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'opens a specific socket' do
|
it 'opens a specific socket' do
|
||||||
expect(TCPSocket).to receive(:new).with(hostname,80).and_return(socket)
|
expect(TCPSocket).to receive(:new).with(hostname,80,{connect_timeout: nil}).and_return(socket)
|
||||||
|
|
||||||
expect(subject.open_socket(hostname,nil,nil,80)).to eq(nil)
|
expect(subject.open_socket(hostname,nil,nil,80)).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'uses a specific domain with the hostname' do
|
it 'uses a specific domain with the hostname' do
|
||||||
expect(TCPSocket).to receive(:new).with("#{hostname}.#{domain}",default_socket).and_return(socket)
|
expect(TCPSocket).to receive(:new).with("#{hostname}.#{domain}",default_socket,{connect_timeout: 5}).and_return(socket)
|
||||||
|
|
||||||
expect(subject.open_socket(hostname,domain)).to eq(nil)
|
expect(subject.open_socket(hostname,domain)).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises error if host is not resolvable' do
|
it 'raises error if host is not resolvable' do
|
||||||
expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_raise(SocketError,'getaddrinfo: No such host is known')
|
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 1}).and_raise(SocketError,'getaddrinfo: No such host is known')
|
||||||
|
|
||||||
expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError)
|
expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises error if socket is not listening' do
|
it 'raises error if socket is not listening' do
|
||||||
expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_raise(SocketError,'No connection could be made because the target machine actively refused it')
|
expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 1}).and_raise(SocketError,'No connection could be made because the target machine actively refused it')
|
||||||
|
|
||||||
expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError)
|
expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue