Sha256: 0196c520a83b9d36dc7188890bc2ca13ba283a2d9d6e898112d126fb2b57da9f

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

require 'libuv'


describe Libuv::Dns do
	before :each do
		@log = []
		@general_failure = []

		@loop = Libuv::Loop.default
		@timeout = @loop.timer do
			@loop.stop
			@general_failure << "test timed out"
		end
		@timeout.start(5000)

		@loop.all(@server, @client, @timeout).catch do |reason|
			@general_failure << reason.inspect
			p "Failed with: #{reason.message}\n#{reason.backtrace.join("\n")}\n"
		end
	end
	
	it "should resolve localhost using IP4", :network => true do
		@loop.run { |logger|
			logger.progress do |level, errorid, error|
				begin
					p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
				rescue Exception
					p 'error in logger'
				end
			end

			@loop.lookup('localhost').then proc { |addrinfo|
				@result = addrinfo[0][0]
				@loop.stop
			}, proc { |err|
				@general_failure << err
				@loop.stop
			}
		}

		expect(@general_failure).to eq([])
		expect(@result).to eq('127.0.0.1')
	end

	it "should resolve localhost using IP6", :network => true do
		@loop.run { |logger|
			logger.progress do |level, errorid, error|
				begin
					p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
				rescue Exception
					p 'error in logger'
				end
			end

			@loop.lookup('localhost', :IPv6).then proc { |addrinfo|
				@result = addrinfo[0][0]
				@loop.stop
			}, proc { |err|
				@general_failure << err
				@loop.stop
			}
		}

		expect(@general_failure).to eq([])
		expect(@result).to eq('::1')
	end

	it "should resolve loop back" do
		@loop.run { |logger|
			logger.progress do |level, errorid, error|
				begin
					p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
				rescue Exception
					p 'error in logger'
				end
			end

			@loop.lookup('127.0.0.1').then proc { |addrinfo|
				@result = addrinfo[0][0]
				@loop.stop
			}, proc { |err|
				@general_failure << err
				@loop.stop
			}
		}

		expect(@general_failure).to eq([])
		expect(@result).to eq('127.0.0.1')
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
libuv-0.11.21 spec/dns_spec.rb
libuv-0.11.20 spec/dns_spec.rb